Skip to content

Commit

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

Reverts #11935 because we removed the correct fallback behaviour of `collapseAliases`

Co-authored-by: Zaid Ajaj <Zaid-Ajaj@users.noreply.github.com>
  • Loading branch information
bors[bot] and Zaid-Ajaj committed Jan 26, 2023
2 parents 30b04f5 + 1233da5 commit 7bcc9e8
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 389 deletions.

This file was deleted.

14 changes: 14 additions & 0 deletions sdk/go/pulumi/alias.go
Expand Up @@ -134,3 +134,17 @@ 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 7bcc9e8

Please sign in to comment.