update edit fix to convert the old patches to patchesStrategicMerge

This commit is contained in:
jingfangliu
2019-07-17 14:16:33 -07:00
parent 3cb6c7f1f4
commit 8c53d77111
8 changed files with 245 additions and 21 deletions

View File

@@ -923,6 +923,107 @@ spec:
`)
}
func TestExtendedPatchWithoutTarget(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/base")
makeCommonFileForExtendedPatchTest(th)
th.WriteK("/app/base", `
resources:
- deployment.yaml
- service.yaml
patches:
- path: patch.yaml
`)
th.WriteF("/app/base/patch.yaml", `
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: busybox
annotations:
new-key: new-value
`)
m, err := th.MakeKustTarget().MakeCustomizedResMap()
if err != nil {
t.Fatalf("Err: %v", err)
}
th.AssertActualEqualsExpected(m, `
apiVersion: apps/v1beta2
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
volumeMounts:
- mountPath: /tmp/ps
name: nginx-persistent-storage
volumes:
- emptyDir: {}
name: nginx-persistent-storage
- configMap:
name: configmap-in-base
name: configmap-in-base
---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
annotations:
new-key: new-value
labels:
app: busybox
name: busybox
spec:
template:
metadata:
labels:
app: busybox
spec:
containers:
- image: busybox
name: busybox
volumeMounts:
- mountPath: /tmp/ps
name: busybox-persistent-storage
volumes:
- emptyDir: {}
name: busybox-persistent-storage
- configMap:
name: configmap-in-base
name: configmap-in-base
---
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx
spec:
ports:
- port: 80
selector:
app: nginx
---
apiVersion: v1
kind: Service
metadata:
labels:
app: busybox
name: busybox
spec:
ports:
- port: 8080
selector:
app: busybox
`)
}
func TestExtendedPatchNoMatchMultiplePatch(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/base")
makeCommonFileForExtendedPatchTest(th)

View File

@@ -200,7 +200,7 @@ func (kt *KustTarget) configureBuiltinPatchTransformer(
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
}
for _, patch := range kt.kustomization.Patches {
c.Target = &patch.Target
c.Target = patch.Target
c.Patch = patch.Patch
c.Path = patch.Path
p := builtin.NewPatchTransformerPlugin()