From 403ede788cc20c755b4492f32e59109ca37784d2 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 12 Apr 2019 11:27:53 +0200 Subject: [PATCH] tests: demonstrate issue with JSON patch when base adds name prefix The expectation is that the base entity can be referenced by its name with prefix, because the overlay shouldn't have to know how the base is generated. But currently the entity is only found when using the name without prefix. Related-To: #972 --- pkg/target/baseandoverlaysmall_test.go | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/pkg/target/baseandoverlaysmall_test.go b/pkg/target/baseandoverlaysmall_test.go index dfcd1fd43..809445c43 100644 --- a/pkg/target/baseandoverlaysmall_test.go +++ b/pkg/target/baseandoverlaysmall_test.go @@ -180,3 +180,62 @@ spec: name: whatever `) } + +func TestSmallOverlayJSONPatch(t *testing.T) { + th := NewKustTestHarness(t, "/app/overlay") + writeSmallBase(th) + th.writeK("/app/overlay", ` +bases: +- ../base +patchesJson6902: +- target: + version: v1 + kind: Service + name: myService # BUG (https://github.com/kubernetes-sigs/kustomize/issues/972): this should be a-myService, because that is what the output for the base contains + path: service-patch.yaml +`) + + th.writeF("/app/overlay/service-patch.yaml", ` +- op: add + path: /spec/selector/backend + value: beagle +`) + m, err := th.makeKustTarget().MakeCustomizedResMap() + if err != nil { + t.Fatalf("Err: %v", err) + } + th.assertActualEqualsExpected(m, ` +apiVersion: v1 +kind: Service +metadata: + labels: + app: myApp + name: a-myService +spec: + ports: + - port: 7002 + selector: + app: myApp + backend: beagle +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: myApp + name: a-myDeployment +spec: + selector: + matchLabels: + app: myApp + template: + metadata: + labels: + app: myApp + backend: awesome + spec: + containers: + - image: whatever + name: whatever +`) +}