kustomize: Configuration-Value nameSuffix is ignored
Whatever pathes are set for the ConfigurationValue nameSuffix are ignored. Only the Pathes from namePrefix are used for the Name-Transformer.
The Module api/internal/target/kusttarget_configplugin.go will just pass the ConfigurationParameter nameSuffix to FieldSpecs of PrefixSuffixTransformer (because the plugin/buildin/prefixsuffixtransformer/PrefixSuffixTransformer.go only supports one fieldSpecs-Array)
This means, that it is not possible to declare some pathes to only receive a Prefix OR a suffix, if both are configured.
I’m trying to expose the namePrefix and nameSuffix values automatically into a ArgoCD-Application Description. When I generate the Application with kustomize, I want to mirror the name-changes into spec/source/kustomize/{namePrefix|nameSuffix}
config.yaml
namePrefix:
- path: metadata/labels/prefix
nameSuffix:
- path: metadata/labels/suffix
test.yaml
kind: Test
metadata:
name: test
labels:
prefix: ""
suffix: ""
kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configurations:
- config.yaml
resources:
- test.yaml
namePrefix: "pre-"
nameSuffix: "-suf"
Expected output
kind: Test
metadata:
labels:
prefix: pre-
suffix: -suf
name: pre-test-suf
Actual output
kind: Test
metadata:
labels:
prefix: pre--suf
suffix: ""
name: pre-test-suf
Kustomize version
3.9.4…4.3.0
Platform
Windows (3.9.4), Linux (4.3.0)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (14 by maintainers)
Commits related to this issue
- Refactor the PrefixSuffixTransformer into separate prefix- and suffix transformers (#4164) — committed to Serializator/kustomize by Serializator 3 years ago
- Refactor the PrefixSuffixTransformer into separate prefix- and suffix transformers (#4164) — committed to Serializator/kustomize by Serializator 3 years ago
@KnVerey, coincidentally I was just working on trying out your approach. It didn’t work out-of-the-box by removing
th.PrepBuiltin("PrefixSuffixTransformer")as the loading option was stilltypes.BploLoadFromFileSys.I added the below line in addition to removing
th.PrepBuiltin("PrefixSuffixTransformer")and (as far I as can tell) it works like you said. Thank you!th.GetPluginConfig().BpLoadingOptions = types.BploUseStaticallyLinkedPlease let me know if you have any other feedback in regards to the above, otherwise I will create a PR 👍🏼
Thank you for the detailed and in-depth feedback @natasha41575, it helped a lot! I made a really rough “prototype” ( https://github.com/Serializator/kustomize/commit/65f6443289f3369d9d8e7847f924f7445c048041) in which I refactored the
PrefixSuffixTransformerinto separate transformers. I ran all tests and they all succeeded.I will start working on refactoring some of the TODOs into the filters, make sure the tests are written for the
PrefixTransformerandSuffixTransformerand fine-tune everything necessary before making a PR.