First-class treatment of identifier transformations #3292
Labels
area/fn-sdk
Typescript SDK
enhancement
New feature or request
triaged
Issue has been triaged by adding an `area/` label
Related to #3155
This is the set-namespace transformer code:
https://github.com/GoogleContainerTools/kpt-functions-catalog/blob/master/functions/go/set-namespace/transformer/namespace.go
A previous version tried to update only namespace values matching the name of the Namespace resource:
GoogleContainerTools/kpt-functions-catalog#844
The problem with that was that it didn't work after kpt pkg update in the case that the upstream introduced a new resource with the original namespace name rather than the transformed namespace name. The desired behavior would be to remap all instances of the original namespace to the new desired namespace.
More generally, name changes are hard to do with just string munging. ensure-name-substring is an example of that:
https://github.com/GoogleContainerTools/kpt-functions-catalog/tree/master/functions/go/ensure-name-substring
We should do a deep dive into how kustomize manages name changes.
We need to explicitly model the object graph, including references to external dependencies, in order to support renaming and eventually other graph transformations.
Terraform, Pulumi, and other tools perform automatic naming and maintain aliases from declarative package-local names (kind of like formal parameters) to the actual resource names, which often contain unpredictable generated suffixes, similar to generated Pod names. In the case of Terraform, the resource names are generated from the module and resource structures, which is problematic when they get refactored.
Rather than (or in addition to) comments, we could annotate resources with the necessary metadata to maintain the mappings to their abstract names and namespaces. We've also discussed using the filenames, but in this case we want to be able to set the namespace of all resources that were in the same Namespace as the abstract Namespace ("example") in the blueprint, so we need that information. If there were references to those objects, we'd need to update those as well.
We were stripping the internal annotations in the package orchestrator, but either way we'd need to pass the annotations through the pipeline in order for them to be available to functions. We should just filter them in the UI rather than in porch.
There are non-KRM identifiers that may need similar transforms, also, such as Config Connector project ids.
cc @yuwenma @justinsb
The text was updated successfully, but these errors were encountered: