mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
fix the regression on merging configmap with different namespace
This commit is contained in:
@@ -57,6 +57,7 @@ type Kunstructured interface {
|
|||||||
GetKind() string
|
GetKind() string
|
||||||
GetName() string
|
GetName() string
|
||||||
SetName(string)
|
SetName(string)
|
||||||
|
SetNamespace(string)
|
||||||
GetLabels() map[string]string
|
GetLabels() map[string]string
|
||||||
SetLabels(map[string]string)
|
SetLabels(map[string]string)
|
||||||
GetAnnotations() map[string]string
|
GetAnnotations() map[string]string
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ func (r *Resource) Replace(other *Resource) {
|
|||||||
r.SetAnnotations(
|
r.SetAnnotations(
|
||||||
mergeStringMaps(other.GetAnnotations(), r.GetAnnotations()))
|
mergeStringMaps(other.GetAnnotations(), r.GetAnnotations()))
|
||||||
r.SetName(other.GetName())
|
r.SetName(other.GetName())
|
||||||
|
r.SetNamespace(other.GetNamespace())
|
||||||
r.copyOtherFields(other)
|
r.copyOtherFields(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,3 +87,43 @@ metadata:
|
|||||||
type: Opaque
|
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