diff --git a/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent/kustomization.yaml b/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent/kustomization.yaml deleted file mode 100644 index fe386b14b..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1beta1 -kind: Kustomization -namePrefix: p1- -configMapGenerator: -- name: com1 - behavior: create - literals: - - from=base diff --git a/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent2/kustomization.yaml b/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent2/kustomization.yaml deleted file mode 100644 index 18b0347bb..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/base/myapp/mycomponent2/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1beta1 -kind: Kustomization -namePrefix: p2- -configMapGenerator: -- name: com2 - behavior: create - literals: - - from=base diff --git a/pkg/commands/build/testdata/testcase-configmaps/expected.diff b/pkg/commands/build/testdata/testcase-configmaps/expected.diff deleted file mode 100644 index 7803718cb..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/expected.diff +++ /dev/null @@ -1,16 +0,0 @@ -diff -u -N /tmp/noop/v1_ConfigMap_com1.yaml /tmp/transformed/v1_ConfigMap_com1.yaml ---- /tmp/noop/v1_ConfigMap_com1.yaml YYYY-MM-DD HH:MM:SS -+++ /tmp/transformed/v1_ConfigMap_com1.yaml YYYY-MM-DD HH:MM:SS -@@ -1,9 +1,11 @@ - apiVersion: v1 - data: -+ baz: qux -+ foo: bar - from: overlay - kind: ConfigMap - metadata: - annotations: {} - creationTimestamp: null - labels: {} -- name: p1-com1-cmdb776d5b -+ name: p1-com1-dhbbm922gd diff --git a/pkg/commands/build/testdata/testcase-configmaps/expected.yaml b/pkg/commands/build/testdata/testcase-configmaps/expected.yaml deleted file mode 100644 index 59656f4ee..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/expected.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -data: - baz: qux - foo: bar - from: overlay -kind: ConfigMap -metadata: - annotations: {} - labels: {} - name: p1-com1-dhbbm922gd ---- -apiVersion: v1 -data: - from: overlay -kind: ConfigMap -metadata: - annotations: {} - labels: {} - name: p2-com2-c4b8md75k9 diff --git a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/kustomization.yaml b/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/kustomization.yaml deleted file mode 100644 index e34a4767b..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/kustomization.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1beta1 -kind: Kustomization -bases: -- myapp/mycomponent -- myapp/mycomponent2 -configMapGenerator: -- name: com1 - behavior: merge - literals: - - foo=bar - - baz=qux \ No newline at end of file diff --git a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent/kustomization.yaml b/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent/kustomization.yaml deleted file mode 100644 index f14834eab..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1beta1 -kind: Kustomization -bases: -- ../../../../base/myapp/mycomponent -configMapGenerator: -- name: com1 - behavior: merge - literals: - - from=overlay diff --git a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent2/kustomization.yaml b/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent2/kustomization.yaml deleted file mode 100644 index f66340c38..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/overlay/dev/myapp/mycomponent2/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1beta1 -kind: Kustomization -bases: -- ../../../../base/myapp/mycomponent2 -configMapGenerator: -- name: com2 - behavior: merge - literals: - - from=overlay diff --git a/pkg/commands/build/testdata/testcase-configmaps/test.yaml b/pkg/commands/build/testdata/testcase-configmaps/test.yaml deleted file mode 100644 index 633d415a7..000000000 --- a/pkg/commands/build/testdata/testcase-configmaps/test.yaml +++ /dev/null @@ -1,5 +0,0 @@ -description: configmap generator overlay -args: [] -filename: testdata/testcase-configmaps/overlay/dev -expectedStdout: testdata/testcase-configmaps/expected.yaml -expectedDiff: testdata/testcase-configmaps/expected.diff diff --git a/pkg/target/configmaps_test.go b/pkg/target/configmaps_test.go new file mode 100644 index 000000000..4de2ae326 --- /dev/null +++ b/pkg/target/configmaps_test.go @@ -0,0 +1,105 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package target + +import ( + "testing" +) + +func TestGenerator1(t *testing.T) { + th := NewKustTestHarness(t, "/app/overlay") + th.writeK("/app/base1", ` +apiVersion: v1beta1 +kind: Kustomization +namePrefix: p1- +configMapGenerator: +- name: com1 + behavior: create + literals: + - from=base +`) + th.writeK("/app/base2", ` +apiVersion: v1beta1 +kind: Kustomization +namePrefix: p2- +configMapGenerator: +- name: com2 + behavior: create + literals: + - from=base +`) + th.writeK("/app/overlay/o1", ` +apiVersion: v1beta1 +kind: Kustomization +bases: +- ../../base1 +configMapGenerator: +- name: com1 + behavior: merge + literals: + - from=overlay +`) + th.writeK("/app/overlay/o2", ` +apiVersion: v1beta1 +kind: Kustomization +bases: +- ../../base2 +configMapGenerator: +- name: com2 + behavior: merge + literals: + - from=overlay +`) + th.writeK("/app/overlay", ` +apiVersion: v1beta1 +kind: Kustomization +bases: +- o1 +- o2 +configMapGenerator: +- name: com1 + behavior: merge + literals: + - foo=bar + - baz=qux +`) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(m, ` +apiVersion: v1 +data: + baz: qux + foo: bar + from: overlay +kind: ConfigMap +metadata: + annotations: {} + labels: {} + name: p1-com1-dhbbm922gd +--- +apiVersion: v1 +data: + from: overlay +kind: ConfigMap +metadata: + annotations: {} + labels: {} + name: p2-com2-c4b8md75k9 +`) +}