mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 18:10:59 +00:00
add test for extended patch with overlapping patches
This commit is contained in:
@@ -922,3 +922,226 @@ spec:
|
||||
app: busybox
|
||||
`)
|
||||
}
|
||||
|
||||
func TestExtendedPatchNoMatchMultiplePatch(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
|
||||
target:
|
||||
name: no-match
|
||||
- path: patch.yaml
|
||||
target:
|
||||
name: busybox
|
||||
kind: Job
|
||||
`)
|
||||
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:
|
||||
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 TestExtendedPatchMultiplePatchOverlapping(t *testing.T) {
|
||||
th := kusttest_test.NewKustTestHarness(t, "/app/base")
|
||||
makeCommonFileForExtendedPatchTest(th)
|
||||
th.WriteK("/app/base", `
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
patches:
|
||||
- path: patch1.yaml
|
||||
target:
|
||||
labelSelector: app=busybox
|
||||
- path: patch2.yaml
|
||||
target:
|
||||
name: busybox
|
||||
kind: Deployment
|
||||
`)
|
||||
th.WriteF("/app/base/patch1.yaml", `
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: busybox
|
||||
annotations:
|
||||
new-key-from-patch1: new-value
|
||||
`)
|
||||
th.WriteF("/app/base/patch2.yaml", `
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: busybox
|
||||
annotations:
|
||||
new-key-from-patch2: 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-from-patch1: new-value
|
||||
new-key-from-patch2: 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:
|
||||
annotations:
|
||||
new-key-from-patch1: new-value
|
||||
labels:
|
||||
app: busybox
|
||||
name: busybox
|
||||
spec:
|
||||
ports:
|
||||
- port: 8080
|
||||
selector:
|
||||
app: busybox
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user