mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
api/resource: add new test for inline options.
This commit is contained in:
@@ -339,8 +339,6 @@ configMapGenerator:
|
|||||||
behavior: replace
|
behavior: replace
|
||||||
literals:
|
literals:
|
||||||
- foo=override-bar
|
- foo=override-bar
|
||||||
options:
|
|
||||||
disableNameSuffixHash: true
|
|
||||||
secretGenerator:
|
secretGenerator:
|
||||||
- name: secret-in-base
|
- name: secret-in-base
|
||||||
behavior: merge
|
behavior: merge
|
||||||
@@ -390,6 +388,165 @@ spec:
|
|||||||
- configMap:
|
- configMap:
|
||||||
name: staging-configmap-in-overlay-dc6fm46dhm
|
name: staging-configmap-in-overlay-dc6fm46dhm
|
||||||
name: configmap-in-overlay
|
name: configmap-in-overlay
|
||||||
|
- configMap:
|
||||||
|
name: staging-team-foo-configmap-in-base-hc6g9dk6g9
|
||||||
|
name: configmap-in-base
|
||||||
|
---
|
||||||
|
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: 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-hc6g9dk6g9
|
||||||
|
---
|
||||||
|
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-k2k4692t9g
|
||||||
|
type: Opaque
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
env: staging
|
||||||
|
team: override-foo
|
||||||
|
name: staging-configmap-in-overlay-dc6fm46dhm
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMergeAndReplaceDisableNameSuffixHashGenerators(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
makeBaseWithGenerators(th)
|
||||||
|
th.WriteF("overlay/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
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", `
|
||||||
|
namePrefix: staging-
|
||||||
|
commonLabels:
|
||||||
|
env: staging
|
||||||
|
team: override-foo
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- deployment.yaml
|
||||||
|
resources:
|
||||||
|
- ../app
|
||||||
|
configMapGenerator:
|
||||||
|
- name: configmap-in-overlay
|
||||||
|
literals:
|
||||||
|
- hello=world
|
||||||
|
options:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
- name: configmap-in-base
|
||||||
|
behavior: replace
|
||||||
|
literals:
|
||||||
|
- foo=override-bar
|
||||||
|
options:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
secretGenerator:
|
||||||
|
- name: secret-in-base
|
||||||
|
behavior: merge
|
||||||
|
literals:
|
||||||
|
- proxy=haproxy
|
||||||
|
options:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
`)
|
||||||
|
m := th.Run("overlay", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
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
|
||||||
|
name: configmap-in-overlay
|
||||||
- configMap:
|
- configMap:
|
||||||
name: staging-team-foo-configmap-in-base
|
name: staging-team-foo-configmap-in-base
|
||||||
name: configmap-in-base
|
name: configmap-in-base
|
||||||
@@ -442,7 +599,7 @@ metadata:
|
|||||||
env: staging
|
env: staging
|
||||||
org: example.com
|
org: example.com
|
||||||
team: override-foo
|
team: override-foo
|
||||||
name: staging-team-foo-secret-in-base-k2k4692t9g
|
name: staging-team-foo-secret-in-base
|
||||||
type: Opaque
|
type: Opaque
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -453,7 +610,7 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
env: staging
|
env: staging
|
||||||
team: override-foo
|
team: override-foo
|
||||||
name: staging-configmap-in-overlay-dc6fm46dhm
|
name: staging-configmap-in-overlay
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user