mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #761 from narg95/varref_mountpath
add volumeMounts/mountPath to varreference
This commit is contained in:
@@ -723,3 +723,80 @@ spec:
|
|||||||
- kustomized-nginx.example.com
|
- kustomized-nginx.example.com
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestVariableRefMounthPath(t *testing.T) {
|
||||||
|
th := NewKustTestHarness(t, "/app/base")
|
||||||
|
th.writeK("/app/base", `
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- namespace.yaml
|
||||||
|
|
||||||
|
vars:
|
||||||
|
- name: NAMESPACE
|
||||||
|
objref:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: my-namespace
|
||||||
|
|
||||||
|
`)
|
||||||
|
th.writeF("/app/base/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: my-deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: app
|
||||||
|
image: busybox
|
||||||
|
volumeMounts:
|
||||||
|
- name: my-volume
|
||||||
|
mountPath: "/$(NAMESPACE)"
|
||||||
|
env:
|
||||||
|
- name: NAMESPACE
|
||||||
|
value: $(NAMESPACE)
|
||||||
|
volumes:
|
||||||
|
- name: my-volume
|
||||||
|
emptyDir: {}
|
||||||
|
`)
|
||||||
|
th.writeF("/app/base/namespace.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: my-namespace
|
||||||
|
`)
|
||||||
|
|
||||||
|
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Err: %v", err)
|
||||||
|
}
|
||||||
|
th.assertActualEqualsExpected(m, `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: my-namespace
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: my-deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: NAMESPACE
|
||||||
|
value: my-namespace
|
||||||
|
image: busybox
|
||||||
|
name: app
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /my-namespace
|
||||||
|
name: my-volume
|
||||||
|
volumes:
|
||||||
|
- emptyDir: {}
|
||||||
|
name: my-volume
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|||||||
@@ -105,5 +105,47 @@ varReference:
|
|||||||
|
|
||||||
- path: spec/tls/hosts
|
- path: spec/tls/hosts
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: StatefulSet
|
||||||
|
|
||||||
|
- path: spec/containers/volumeMounts/mountPath
|
||||||
|
kind: Pod
|
||||||
|
|
||||||
|
- path: spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: Pod
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: ReplicaSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: ReplicaSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: Job
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: Job
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: CronJob
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: CronJob
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: DaemonSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: DaemonSet
|
||||||
|
|
||||||
|
- path: spec/template/spec/containers/volumeMounts/mountPath
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
|
- path: spec/template/spec/initContainers/volumeMounts/mountPath
|
||||||
|
kind: Deployment
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user