Skip to content

Commit

Permalink
Merge #11935
Browse files Browse the repository at this point in the history
11935: [go/sdk] Delegate alias computation to the engine r=Zaid-Ajaj a=Zaid-Ajaj


# Description

This PR removes the use of `collapseAliases` from the go SDK which used to calculate aliases of resources from `ResourceOptions` and their inherited child aliases (a.k.a. alias explosion) and starts using the new alias specification `pulumirpc.Alias` that is handled by the engine in a language-agnostic manner. 

This PR removes `aliases: []URNOutput` from `resourceState` because we no longer have to keep track of them in `makeResourceState` but instead calculate them in `prepareResourceInputs`. 

Fixes #11066
Potentially addresses #11697 

## Checklist

<!--- Please provide details if the checkbox below is to be left unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the Pulumi Service,
then the service should honor older versions of the CLI where this change would not exist.
You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version
  <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. -->


Co-authored-by: Zaid Ajaj <zaid.naom@gmail.com>
  • Loading branch information
bors[bot] and Zaid-Ajaj committed Jan 26, 2023
2 parents cbde0fd + c3cbeb3 commit 30b04f5
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 187 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: sdk/go
description: Delegate alias computation to the engine
14 changes: 0 additions & 14 deletions sdk/go/pulumi/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,3 @@ func CreateURN(name, t, parent, project, stack StringInput) URNOutput {
return createURN(a[0].(string), a[1].(string), a[2].(string), a[3].(string), a[4].(string))
}).(URNOutput)
}

// inheritedChildAlias computes the alias that should be applied to a child based on an alias applied to it's parent.
// This may involve changing the name of the resource in cases where the resource has a named derived from the name of
// the parent, and the parent name changed.
func inheritedChildAlias(childName, parentName, childType, project, stack string, parentURN URNOutput) URNOutput {
aliasName := StringInput(String(childName))
if strings.HasPrefix(childName, parentName) {
aliasName = parentURN.ApplyT(func(urn URN) string {
parentPrefix := urn[strings.LastIndex(string(urn), "::")+2:]
return string(parentPrefix) + childName[len(parentName):]
}).(StringOutput)
}
return CreateURN(aliasName, String(childType), parentURN.ToStringOutput(), String(project), String(stack))
}

0 comments on commit 30b04f5

Please sign in to comment.