mirror of
https://github.com/truenas/charts.git
synced 2026-06-16 06:58:45 +08:00
add tests for volMounts
This commit is contained in:
@@ -448,6 +448,107 @@ tests:
|
||||
mountPath: /some/path
|
||||
readOnly: true
|
||||
|
||||
- it: should pass with cert mounted as volume with subPath
|
||||
set:
|
||||
image: *image
|
||||
ixCertificates:
|
||||
"1":
|
||||
certificate: some_cert
|
||||
key: some_key
|
||||
scaleCertificate:
|
||||
cert-name:
|
||||
enabled: false
|
||||
id: 1
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
persistence:
|
||||
cert-vol:
|
||||
enabled: true
|
||||
type: secret
|
||||
objectName: cert-name
|
||||
readOnly: true
|
||||
targetSelector:
|
||||
workload-name:
|
||||
container-name1:
|
||||
mountPath: /some/path/cert.crt
|
||||
readOnly: true
|
||||
subPath: cert.crt
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: cert-vol
|
||||
mountPath: /some/path/cert.crt
|
||||
readOnly: true
|
||||
subPath: cert.crt
|
||||
|
||||
- it: should pass with cert mounted as volume with subPath
|
||||
set:
|
||||
image: *image
|
||||
ixCertificates:
|
||||
"1":
|
||||
certificate: some_cert
|
||||
key: some_key
|
||||
scaleCertificate:
|
||||
cert-name:
|
||||
enabled: false
|
||||
id: 1
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
persistence:
|
||||
cert-vol:
|
||||
enabled: true
|
||||
type: secret
|
||||
objectName: cert-name
|
||||
readOnly: true
|
||||
items:
|
||||
- key: crt
|
||||
path: cert.crt
|
||||
targetSelector:
|
||||
workload-name:
|
||||
container-name1:
|
||||
mountPath: /some/path
|
||||
readOnly: true
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: cert-vol
|
||||
mountPath: /some/path
|
||||
readOnly: true
|
||||
|
||||
# Failures
|
||||
- it: should fail with invalid mountPropagation
|
||||
set:
|
||||
|
||||
@@ -101,6 +101,22 @@ tests:
|
||||
|
||||
# Failures
|
||||
- it: should fail without objectName in configmap
|
||||
set:
|
||||
workload:
|
||||
some-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: configmap
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected non-empty <objectName> on <configmap> type
|
||||
|
||||
- it: should fail with empty objectName in configmap
|
||||
set:
|
||||
workload:
|
||||
some-workload:
|
||||
|
||||
@@ -117,6 +117,23 @@ tests:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected non-empty <objectName> on <secret> type
|
||||
|
||||
- it: should fail with empty objectName in secret
|
||||
set:
|
||||
workload:
|
||||
some-workload:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec: {}
|
||||
persistence:
|
||||
volume1:
|
||||
enabled: true
|
||||
type: secret
|
||||
objectName: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Persistence - Expected non-empty <objectName> on <secret> type
|
||||
|
||||
- it: should fail with defaultMode not a string in secret
|
||||
set:
|
||||
workload:
|
||||
|
||||
@@ -41,8 +41,6 @@ You can mount certificate as a secret using the following snippet:
|
||||
scaleCertificate:
|
||||
cert-name:
|
||||
enabled: false
|
||||
labels: {}
|
||||
annotations: {}
|
||||
id: 1
|
||||
|
||||
persistence:
|
||||
|
||||
@@ -44,7 +44,6 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- end -}}
|
||||
|
||||
{{/* TODO:
|
||||
volumeMounts
|
||||
probes
|
||||
|
||||
env
|
||||
|
||||
@@ -8,6 +8,10 @@ objectData: The object data to be used to render the volume.
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if not $objectData.objectName -}}
|
||||
{{- fail "Persistence - Expected non-empty <objectName> on <configmap> type" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $objectName := tpl $objectData.objectName $rootCtx -}}
|
||||
{{- $expandName := true -}}
|
||||
{{- if kindIs "bool" $objectData.expandObjectName -}}
|
||||
@@ -20,10 +24,6 @@ objectData: The object data to be used to render the volume.
|
||||
|
||||
{{- $defMode := "" -}}
|
||||
|
||||
{{- if not $objectData.objectName -}}
|
||||
{{- fail "Persistence - Expected non-empty <objectName> on <configmap> type" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if (and $objectData.defaultMode (not (kindIs "string" $objectData.defaultMode))) -}}
|
||||
{{- fail (printf "Persistence - Expected <defaultMode> to be [string], but got [%s]" (kindOf $objectData.defaultMode)) -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -8,6 +8,10 @@ objectData: The object data to be used to render the volume.
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if not $objectData.objectName -}}
|
||||
{{- fail "Persistence - Expected non-empty <objectName> on <secret> type" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $objectName := tpl $objectData.objectName $rootCtx -}}
|
||||
{{- $expandName := true -}}
|
||||
{{- if kindIs "bool" $objectData.expandObjectName -}}
|
||||
@@ -20,10 +24,6 @@ objectData: The object data to be used to render the volume.
|
||||
|
||||
{{- $defMode := "" -}}
|
||||
|
||||
{{- if not $objectData.objectName -}}
|
||||
{{- fail "Persistence - Expected non-empty <objectName> on <secret> type" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if (and $objectData.defaultMode (not (kindIs "string" $objectData.defaultMode))) -}}
|
||||
{{- fail (printf "Persistence - Expected <defaultMode> to be [string], but got [%s]" (kindOf $objectData.defaultMode)) -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user