Skip to content

Commit

Permalink
Merge pull request #1328 from Liujingfang1/cmgenerator
Browse files Browse the repository at this point in the history
fix the regression on merging configmap with different namespace
  • Loading branch information
k8s-ci-robot authored Jul 9, 2019
2 parents 08400d7 + 49b3247 commit 672bda0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/ifc/ifc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Kunstructured interface {
GetKind() string
GetName() string
SetName(string)
SetNamespace(string)
GetLabels() map[string]string
SetLabels(map[string]string)
GetAnnotations() map[string]string
Expand Down
1 change: 1 addition & 0 deletions pkg/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (r *Resource) Replace(other *Resource) {
r.SetAnnotations(
mergeStringMaps(other.GetAnnotations(), r.GetAnnotations()))
r.SetName(other.GetName())
r.SetNamespace(other.GetNamespace())
r.copyOtherFields(other)
}

Expand Down
40 changes: 40 additions & 0 deletions pkg/target/namespacedgenerators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,43 @@ metadata:
type: Opaque
`)
}

func TestNamespacedGeneratorWithOverlays(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/overlay")
th.WriteK("/app/base", `
namespace: base
configMapGenerator:
- name: testCase
literals:
- base=true
`)
th.WriteK("/app/overlay", `
resources:
- ../base
namespace: overlay
configMapGenerator:
- name: testCase
behavior: merge
literals:
- overlay=true
`)
m, err := th.MakeKustTarget().MakeCustomizedResMap()
if err != nil {
t.Fatalf("Err: %v", err)
}
th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
base: "true"
overlay: "true"
kind: ConfigMap
metadata:
annotations: {}
labels: {}
name: testCase-4g75kbk6gm
namespace: overlay
`)
}

0 comments on commit 672bda0

Please sign in to comment.