Skip to content

Commit 6cf7014

Browse files
authored
Merge pull request #4919 from ChristopherFry/cfry/name-suffix-transformer
Allow overriding of name suffix transformer default configuration
2 parents 2db573b + 8a6602d commit 6cf7014

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

api/internal/plugins/builtinconfig/transformerconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func MakeTransformerConfig(
6060
// sortFields provides determinism in logging, tests, etc.
6161
func (t *TransformerConfig) sortFields() {
6262
sort.Sort(t.NamePrefix)
63+
sort.Sort(t.NameSuffix)
6364
sort.Sort(t.NameSpace)
6465
sort.Sort(t.CommonLabels)
6566
sort.Sort(t.TemplateLabels)

api/internal/target/kusttarget_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,14 @@ apiVersion: kustomize.config.k8s.io/v1beta1
265265
kind: Kustomization
266266
namePrefix: foo-
267267
nameSuffix: -bar
268+
namespace: ns1
268269
resources:
269270
- deployment.yaml
270271
- config.yaml
271272
- secret.yaml
272273
configurations:
273274
- name-prefix-rules.yaml
275+
- name-suffix-rules.yaml
274276
`)
275277
th.WriteF("/merge-config/name-prefix-rules.yaml", `
276278
namePrefix:
@@ -280,6 +282,15 @@ namePrefix:
280282
- path: metadata/name
281283
apiVersion: v1
282284
kind: Secret
285+
`)
286+
th.WriteF("/merge-config/name-suffix-rules.yaml", `
287+
nameSuffix:
288+
- path: metadata/name
289+
apiVersion: v1
290+
kind: ConfigMap
291+
- path: metadata/name
292+
apiVersion: v1
293+
kind: Deployment
283294
`)
284295
th.WriteF("/merge-config/deployment.yaml", `
285296
apiVersion: apps/v1
@@ -308,19 +319,22 @@ metadata:
308319
"apiVersion": "apps/v1",
309320
"kind": "Deployment",
310321
"metadata": map[string]interface{}{
311-
"name": "foo-deployment1-bar",
322+
"name": "foo-deployment1-bar",
323+
"namespace": "ns1",
312324
},
313325
}), resFactory.FromMapWithName("config", map[string]interface{}{
314326
"apiVersion": "v1",
315327
"kind": "ConfigMap",
316328
"metadata": map[string]interface{}{
317-
"name": "config-bar",
329+
"name": "config-bar",
330+
"namespace": "ns1",
318331
},
319332
}), resFactory.FromMapWithName("secret", map[string]interface{}{
320333
"apiVersion": "v1",
321334
"kind": "Secret",
322335
"metadata": map[string]interface{}{
323-
"name": "foo-secret-bar",
336+
"name": "foo-secret",
337+
"namespace": "ns1",
324338
},
325339
}),
326340
}

0 commit comments

Comments
 (0)