mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Convert generator merge and replace tests to in-memory.
This commit is contained in:
@@ -1,85 +0,0 @@
|
|||||||
diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml
|
|
||||||
--- /tmp/noop/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -1,14 +1,27 @@
|
|
||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
+ annotations:
|
|
||||||
+ note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
- app: nginx
|
|
||||||
- name: nginx
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
+ name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
+ selector:
|
|
||||||
+ matchLabels:
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
+ annotations:
|
|
||||||
+ note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
- app: nginx
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
diff -u -N /tmp/noop/networking.k8s.io_v1_NetworkPolicy_nginx.yaml /tmp/transformed/networking.k8s.io_v1_NetworkPolicy_nginx.yaml
|
|
||||||
--- /tmp/noop/networking.k8s.io_v1_NetworkPolicy_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/networking.k8s.io_v1_NetworkPolicy_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -1,13 +1,21 @@
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: NetworkPolicy
|
|
||||||
metadata:
|
|
||||||
- name: nginx
|
|
||||||
+ annotations:
|
|
||||||
+ note: This is a test annotation
|
|
||||||
+ labels:
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
+ name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ingress:
|
|
||||||
- from:
|
|
||||||
- podSelector:
|
|
||||||
matchLabels:
|
|
||||||
- app: nginx
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
podSelector:
|
|
||||||
matchExpressions:
|
|
||||||
- key: app
|
|
||||||
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
|
||||||
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -1,11 +1,17 @@
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
+ annotations:
|
|
||||||
+ note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
- app: nginx
|
|
||||||
- name: nginx
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
+ name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
- app: nginx
|
|
||||||
+ app: mynginx
|
|
||||||
+ org: example.com
|
|
||||||
+ team: foo
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
---
|
|
||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
name: nginx
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: NetworkPolicy
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
name: team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ingress:
|
|
||||||
- from:
|
|
||||||
- podSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
podSelector:
|
|
||||||
matchExpressions:
|
|
||||||
- key: app
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- test
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
apiVersion: v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
namePrefix: team-foo-
|
|
||||||
commonLabels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
commonAnnotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
resources:
|
|
||||||
- resources/deployment.yaml
|
|
||||||
- resources/networkpolicy.yaml
|
|
||||||
- resources/service.yaml
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: nginx
|
|
||||||
image: nginx
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: NetworkPolicy
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
spec:
|
|
||||||
podSelector:
|
|
||||||
matchExpressions:
|
|
||||||
- {key: app, operator: In, values: [test]}
|
|
||||||
ingress:
|
|
||||||
- from:
|
|
||||||
- podSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: nginx
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
app: nginx
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
description: base only
|
|
||||||
args: []
|
|
||||||
filename: testdata/testcase-base-only/in
|
|
||||||
expectedStdout: testdata/testcase-base-only/expected.yaml
|
|
||||||
expectedDiff: testdata/testcase-base-only/expected.diff
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml
|
|
||||||
--- /tmp/noop/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/apps_v1beta2_Deployment_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -5,23 +5,26 @@
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
- name: team-foo-nginx
|
|
||||||
+ team: override-foo
|
|
||||||
+ name: staging-team-foo-nginx
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
+ team: override-foo
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
+ team: override-foo
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
@@ -30,8 +33,12 @@
|
|
||||||
- mountPath: /tmp/ps
|
|
||||||
name: nginx-persistent-storage
|
|
||||||
volumes:
|
|
||||||
- - emptyDir: {}
|
|
||||||
+ - gcePersistentDisk:
|
|
||||||
+ pdName: nginx-persistent-storage
|
|
||||||
name: nginx-persistent-storage
|
|
||||||
- configMap:
|
|
||||||
- name: team-foo-configmap-in-base-bbdmdh7m8t
|
|
||||||
+ name: staging-configmap-in-overlay-k7cbc75tg8
|
|
||||||
+ name: configmap-in-overlay
|
|
||||||
+ - configMap:
|
|
||||||
+ name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
|
||||||
name: configmap-in-base
|
|
||||||
diff -u -N /tmp/noop/v1_ConfigMap_configmap-in-base.yaml /tmp/transformed/v1_ConfigMap_configmap-in-base.yaml
|
|
||||||
--- /tmp/noop/v1_ConfigMap_configmap-in-base.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/v1_ConfigMap_configmap-in-base.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -1,6 +1,6 @@
|
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
- foo: bar
|
|
||||||
+ foo: override-bar
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
@@ -8,6 +8,7 @@
|
|
||||||
creationTimestamp: null
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
- name: team-foo-configmap-in-base-bbdmdh7m8t
|
|
||||||
+ team: override-foo
|
|
||||||
+ name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
|
||||||
diff -u -N /tmp/noop/v1_ConfigMap_configmap-in-overlay.yaml /tmp/transformed/v1_ConfigMap_configmap-in-overlay.yaml
|
|
||||||
--- /tmp/noop/v1_ConfigMap_configmap-in-overlay.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/v1_ConfigMap_configmap-in-overlay.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -0,0 +1,10 @@
|
|
||||||
+apiVersion: v1
|
|
||||||
+data:
|
|
||||||
+ hello: world
|
|
||||||
+kind: ConfigMap
|
|
||||||
+metadata:
|
|
||||||
+ creationTimestamp: null
|
|
||||||
+ labels:
|
|
||||||
+ env: staging
|
|
||||||
+ team: override-foo
|
|
||||||
+ name: staging-configmap-in-overlay-k7cbc75tg8
|
|
||||||
diff -u -N /tmp/noop/v1_Secret_secret-in-base.yaml /tmp/transformed/v1_Secret_secret-in-base.yaml
|
|
||||||
--- /tmp/noop/v1_Secret_secret-in-base.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/v1_Secret_secret-in-base.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -1,6 +1,7 @@
|
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
password: c29tZXB3
|
|
||||||
+ proxy: aGFwcm94eQ==
|
|
||||||
username: YWRtaW4=
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
@@ -9,7 +10,8 @@
|
|
||||||
creationTimestamp: null
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
- name: team-foo-secret-in-base-tkm7hhtf8d
|
|
||||||
+ team: override-foo
|
|
||||||
+ name: staging-team-foo-secret-in-base-c8db7gk2m2
|
|
||||||
type: Opaque
|
|
||||||
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
|
||||||
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
|
||||||
@@ -5,13 +5,15 @@
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
- name: team-foo-nginx
|
|
||||||
+ team: override-foo
|
|
||||||
+ name: staging-team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
app: mynginx
|
|
||||||
+ env: staging
|
|
||||||
org: example.com
|
|
||||||
- team: foo
|
|
||||||
+ team: override-foo
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
foo: override-bar
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
hello: world
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
env: staging
|
|
||||||
team: override-foo
|
|
||||||
name: staging-configmap-in-overlay-k7cbc75tg8
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
data:
|
|
||||||
password: c29tZXB3
|
|
||||||
proxy: aGFwcm94eQ==
|
|
||||||
username: YWRtaW4=
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
name: staging-team-foo-secret-in-base-c8db7gk2m2
|
|
||||||
type: Opaque
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
name: staging-team-foo-nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
---
|
|
||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
name: staging-team-foo-nginx
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
labels:
|
|
||||||
app: mynginx
|
|
||||||
env: staging
|
|
||||||
org: example.com
|
|
||||||
team: override-foo
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- image: nginx
|
|
||||||
name: nginx
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /tmp/ps
|
|
||||||
name: nginx-persistent-storage
|
|
||||||
volumes:
|
|
||||||
- gcePersistentDisk:
|
|
||||||
pdName: nginx-persistent-storage
|
|
||||||
name: nginx-persistent-storage
|
|
||||||
- configMap:
|
|
||||||
name: staging-configmap-in-overlay-k7cbc75tg8
|
|
||||||
name: configmap-in-overlay
|
|
||||||
- configMap:
|
|
||||||
name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
|
||||||
name: configmap-in-base
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
volumes:
|
|
||||||
- name: nginx-persistent-storage
|
|
||||||
emptyDir: null
|
|
||||||
gcePersistentDisk:
|
|
||||||
pdName: nginx-persistent-storage
|
|
||||||
- configMap:
|
|
||||||
name: configmap-in-overlay
|
|
||||||
name: configmap-in-overlay
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
apiVersion: v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
namePrefix: staging-
|
|
||||||
commonLabels:
|
|
||||||
env: staging
|
|
||||||
team: override-foo
|
|
||||||
patchesStrategicMerge:
|
|
||||||
- deployment.yaml
|
|
||||||
bases:
|
|
||||||
- ../package/
|
|
||||||
configMapGenerator:
|
|
||||||
- name: configmap-in-overlay
|
|
||||||
literals:
|
|
||||||
- hello=world
|
|
||||||
- name: configmap-in-base
|
|
||||||
behavior: replace
|
|
||||||
literals:
|
|
||||||
- foo=override-bar
|
|
||||||
secretGenerator:
|
|
||||||
- name: secret-in-base
|
|
||||||
behavior: merge
|
|
||||||
commands:
|
|
||||||
proxy: "printf haproxy"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
apiVersion: apps/v1beta2
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: nginx
|
|
||||||
image: nginx
|
|
||||||
volumeMounts:
|
|
||||||
- name: nginx-persistent-storage
|
|
||||||
mountPath: /tmp/ps
|
|
||||||
volumes:
|
|
||||||
- name: nginx-persistent-storage
|
|
||||||
emptyDir: {}
|
|
||||||
- configMap:
|
|
||||||
name: configmap-in-base
|
|
||||||
name: configmap-in-base
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
apiVersion: v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
namePrefix: team-foo-
|
|
||||||
commonLabels:
|
|
||||||
app: mynginx
|
|
||||||
org: example.com
|
|
||||||
team: foo
|
|
||||||
commonAnnotations:
|
|
||||||
note: This is a test annotation
|
|
||||||
resources:
|
|
||||||
- deployment.yaml
|
|
||||||
- service.yaml
|
|
||||||
configMapGenerator:
|
|
||||||
- name: configmap-in-base
|
|
||||||
literals:
|
|
||||||
- foo=bar
|
|
||||||
secretGenerator:
|
|
||||||
- name: secret-in-base
|
|
||||||
commands:
|
|
||||||
username: "printf admin"
|
|
||||||
password: "printf somepw"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: nginx
|
|
||||||
labels:
|
|
||||||
app: nginx
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
selector:
|
|
||||||
app: nginx
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
description: single overlay
|
|
||||||
args: []
|
|
||||||
filename: testdata/testcase-single-overlay/in/overlay/
|
|
||||||
expectedStdout: testdata/testcase-single-overlay/expected.yaml
|
|
||||||
expectedDiff: testdata/testcase-single-overlay/expected.diff
|
|
||||||
479
pkg/target/generatormergeandreplace_test.go
Normal file
479
pkg/target/generatormergeandreplace_test.go
Normal file
@@ -0,0 +1,479 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package target
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimpleBase(t *testing.T) {
|
||||||
|
th := NewKustTestHarness(t, "/app/base")
|
||||||
|
th.writeK("/app/base", `
|
||||||
|
apiVersion: v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namePrefix: team-foo-
|
||||||
|
commonLabels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
commonAnnotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- networkpolicy.yaml
|
||||||
|
- service.yaml
|
||||||
|
`)
|
||||||
|
th.writeF("/app/base/service.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: nginx
|
||||||
|
`)
|
||||||
|
th.writeF("/app/base/networkpolicy.yaml", `
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- {key: app, operator: In, values: [test]}
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: nginx
|
||||||
|
`)
|
||||||
|
th.writeF("/app/base/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
`)
|
||||||
|
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
th.assertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
---
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
podSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: app
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- test
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBaseWithGenerators(th *KustTestHarness) {
|
||||||
|
th.writeK("/app", `
|
||||||
|
apiVersion: v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namePrefix: team-foo-
|
||||||
|
commonLabels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
commonAnnotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: configmap-in-base
|
||||||
|
literals:
|
||||||
|
- foo=bar
|
||||||
|
secretGenerator:
|
||||||
|
- name: secret-in-base
|
||||||
|
commands:
|
||||||
|
username: "printf admin"
|
||||||
|
password: "printf somepw"
|
||||||
|
`)
|
||||||
|
th.writeF("/app/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
mountPath: /tmp/ps
|
||||||
|
volumes:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
emptyDir: {}
|
||||||
|
- configMap:
|
||||||
|
name: configmap-in-base
|
||||||
|
name: configmap-in-base
|
||||||
|
`)
|
||||||
|
th.writeF("/app/service.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: nginx
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBaseWithGeneratorsAlone(t *testing.T) {
|
||||||
|
th := NewKustTestHarness(t, "/app")
|
||||||
|
makeBaseWithGenerators(th)
|
||||||
|
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
th.assertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-configmap-in-base-bbdmdh7m8t
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
password: c29tZXB3
|
||||||
|
username: YWRtaW4=
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-secret-in-base-tkm7hhtf8d
|
||||||
|
type: Opaque
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: team-foo-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /tmp/ps
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
volumes:
|
||||||
|
- emptyDir: {}
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: team-foo-configmap-in-base-bbdmdh7m8t
|
||||||
|
name: configmap-in-base
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeAndReplaceGenerators(t *testing.T) {
|
||||||
|
th := NewKustTestHarness(t, "/overlay")
|
||||||
|
makeBaseWithGenerators(th)
|
||||||
|
th.writeF("/overlay/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: nginx-persistent-storage
|
||||||
|
emptyDir: null
|
||||||
|
gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: configmap-in-overlay
|
||||||
|
name: configmap-in-overlay
|
||||||
|
`)
|
||||||
|
th.writeK("/overlay", `
|
||||||
|
apiVersion: v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namePrefix: staging-
|
||||||
|
commonLabels:
|
||||||
|
env: staging
|
||||||
|
team: override-foo
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- deployment.yaml
|
||||||
|
bases:
|
||||||
|
- ../app
|
||||||
|
configMapGenerator:
|
||||||
|
- name: configmap-in-overlay
|
||||||
|
literals:
|
||||||
|
- hello=world
|
||||||
|
- name: configmap-in-base
|
||||||
|
behavior: replace
|
||||||
|
literals:
|
||||||
|
- foo=override-bar
|
||||||
|
secretGenerator:
|
||||||
|
- name: secret-in-base
|
||||||
|
behavior: merge
|
||||||
|
commands:
|
||||||
|
proxy: "printf haproxy"
|
||||||
|
`)
|
||||||
|
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
th.assertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: override-bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
env: staging
|
||||||
|
team: override-foo
|
||||||
|
name: staging-configmap-in-overlay-k7cbc75tg8
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
password: c29tZXB3
|
||||||
|
proxy: aGFwcm94eQ==
|
||||||
|
username: YWRtaW4=
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
name: staging-team-foo-secret-in-base-c8db7gk2m2
|
||||||
|
type: Opaque
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
selector:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1beta2
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
name: staging-team-foo-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: override-foo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: nginx
|
||||||
|
name: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /tmp/ps
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
volumes:
|
||||||
|
- gcePersistentDisk:
|
||||||
|
pdName: nginx-persistent-storage
|
||||||
|
name: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: staging-configmap-in-overlay-k7cbc75tg8
|
||||||
|
name: configmap-in-overlay
|
||||||
|
- configMap:
|
||||||
|
name: staging-team-foo-configmap-in-base-gh9d7t85gb
|
||||||
|
name: configmap-in-base
|
||||||
|
`)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user