mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #1328 from Liujingfang1/cmgenerator
fix the regression on merging configmap with different namespace
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user