Skip to content

Commit

Permalink
Merge pull request #4753 from kubernetes-sigs/revert-4751-fix-4717
Browse files Browse the repository at this point in the history
Revert "[address #4717] create template/metadata when using includeTemplates if not present"
  • Loading branch information
KnVerey authored Aug 10, 2022
2 parents 91e002a + 5762794 commit 416eed9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
2 changes: 1 addition & 1 deletion api/internal/target/kusttarget_configplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
} else {
// merge spec/template/metadata fieldSpec if includeTemplate flag is true
if label.IncludeTemplates {
fss, err = fss.MergeOne(types.FieldSpec{Path: "spec/template/metadata/labels", CreateIfNotPresent: true})
fss, err = fss.MergeOne(types.FieldSpec{Path: "spec/template/metadata/labels", CreateIfNotPresent: false})
if err != nil {
return nil, errors.Wrap(err, "failed to merge template fieldSpec")
}
Expand Down
63 changes: 0 additions & 63 deletions api/krusty/inlinelabels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,66 +160,3 @@ spec:
foo: bar
`)
}

func TestKustomizationLabelsInTemplateWhenLabelsIsNil(t *testing.T) {
th := kusttest_test.MakeHarness(t)
th.WriteF("app/deployment.yaml", `
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment
spec:
replicas: 1
template:
spec:
containers:
- name: test-server
image: test-server
`)
th.WriteK("/app", `
resources:
- deployment.yaml
commonLabels:
app: test-server
labels:
- pairs:
app.kubernetes.io/component: a
app.kubernetes.io/instance: b
app.kubernetes.io/name: c
app.kubernetes.io/part-of: d
includeSelectors: false
includeTemplates: true
`)
m := th.Run("/app", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: test-server
app.kubernetes.io/component: a
app.kubernetes.io/instance: b
app.kubernetes.io/name: c
app.kubernetes.io/part-of: d
name: deployment
spec:
replicas: 1
selector:
matchLabels:
app: test-server
template:
metadata:
labels:
app: test-server
app.kubernetes.io/component: a
app.kubernetes.io/instance: b
app.kubernetes.io/name: c
app.kubernetes.io/part-of: d
spec:
containers:
- image: test-server
name: test-server
`)
}

0 comments on commit 416eed9

Please sign in to comment.