Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First-class treatment of identifier transformations #3292

Open
bgrant0607 opened this issue Jun 7, 2022 · 3 comments
Open

First-class treatment of identifier transformations #3292

bgrant0607 opened this issue Jun 7, 2022 · 3 comments
Assignees
Labels
area/fn-sdk Typescript SDK enhancement New feature or request triaged Issue has been triaged by adding an `area/` label

Comments

@bgrant0607
Copy link
Contributor

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

@bgrant0607 bgrant0607 added the enhancement New feature or request label Jun 7, 2022
@yuwenma yuwenma self-assigned this Jun 10, 2022
@yuwenma
Copy link
Contributor

yuwenma commented Jun 14, 2022

Here's the design proposal. I'd like to keep that as a google doc for easy commenting and discussion. And I'll convert that to a PR in https://github.com/GoogleContainerTools/kpt/tree/main/docs/design-docs

@bgrant0607
Copy link
Contributor Author

Thanks! I'm reviewing it. The analysis of kustomize's behavior definitely will be helpful to include in a design doc.

@wleese
Copy link
Contributor

wleese commented Jul 18, 2022

From slack: when copying multiple blueprints into a new deployable package for my application, I get this nice error about duplicate ConfigMap resource names. I blindly use the name "setters" for my setters.yaml config in multiple packages. I don't like the idea of giving them unique names manually, because say someone kpt pkg get's my package twice with different names. The Kptfile nicely has that (unique) name, but the setters.yaml doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fn-sdk Typescript SDK enhancement New feature or request triaged Issue has been triaged by adding an `area/` label
Projects
None yet
Development

No branches or pull requests

4 participants