-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
nameSuffix
transformer not honoring fieldspec
#4883
Comments
The issue seems to be that it is not overridding the default config that targets metadata/name in all resources with the more specific one you provided. Or, perhaps it is somehow running twice, once with the default config and once with the one you specified? That seems less likely but would also have the observed result. Interestingly, # kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
namePrefix: prefix-
nameSuffix: -suffix
configurations:
- my-config.yaml # my-config.yaml
namePrefix:
- path: metadata/name
apiVersion: apps/v1
kind: Deployment
nameSuffix:
- path: metadata/name
apiVersion: apps/v1
kind: Deployment Then I get: apiVersion: v1
kind: Namespace
metadata:
name: ns1 # good
---
apiVersion: v1
kind: ConfigMap
metadata:
name: config-suffix # prefix correctly skipped, suffix incorrectly present
---
apiVersion: v1
kind: Secret
metadata:
name: secret-suffix # prefix correctly skipped, suffix incorrectly present
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prefix-deployment1-suffix-suffix # prefix correctly applied, suffix duplicated This is a bug that we should fix, but I also have a workaround for you: if you invoke the transformer through the transformers field, the fieldspecs are replaced rather than merged, so you should get the behaviour you want: # kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
transformers:
- transformer.yaml # transformer.yaml
apiVersion: builtin
kind: PrefixSuffixTransformer
metadata:
name: suffixer
suffix: "-suffix"
fieldSpecs:
- path: metadata/name
apiVersion: apps/v1
kind: Deployment /triage accepted @ChristopherFry I see you've been working on tests in #4882 that currently demonstrate the prefix transformer behaves correctly in this respect. Perhaps you'd be interested in looking into this related bug? |
The cause looks like it might be due to
|
I'll be happy to take this bug on. Thanks! /assign |
Describe the bug
Following Transformer Configurations, the
nameSuffix
transformer is not honoring the FieldSpec to limit the number of resources to be transformed.Files that can reproduce the issue
Expected output
The expectation is when
kustomize build .
is executed, only the Deployment resource's name will be updated with the suffix-suffix
appended.Actual output
Running
kustomize build
, the names of all the resources (excluding the Namespace resource) have the-suffix
appended, with the Deployment resource having the suffix appended twice.Kustomize version
The text was updated successfully, but these errors were encountered: