fix SFS volumeMounts

This commit is contained in:
Stavros kois
2024-03-10 17:22:33 +02:00
parent d3261634d3
commit 75fd2298b8
2 changed files with 30 additions and 2 deletions

View File

@@ -11,15 +11,28 @@ tests:
my-volume1:
enabled: true
type: vct
mountPath: /some/path1
my-volume2:
enabled: true
type: vct
mountPath: /some/path2
workload:
main:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
podSpec:
containers:
main:
enabled: true
primary: true
probes:
liveness:
enabled: false
readiness:
enabled: false
startup:
enabled: false
asserts:
- documentIndex: &statefulSetDoc 0
isKind:
@@ -31,7 +44,15 @@ tests:
equal:
path: spec.volumeClaimTemplates[0].metadata.name
value: test-release-name-common-test-my-volume1
- documentIndex: *statefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[1].name
value: test-release-name-common-test-my-volume1
- documentIndex: *statefulSetDoc
equal:
path: spec.volumeClaimTemplates[1].metadata.name
value: test-release-name-common-test-my-volume2
- documentIndex: *statefulSetDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[2].name
value: test-release-name-common-test-my-volume2

View File

@@ -22,7 +22,9 @@ objectData: The object data to be used to render the container.
{{- if and (eq $enabled "true") (not (and (eq $persistenceValues.type "vct") (ne $objectData.podType "StatefulSet"))) -}}
{{/* Dont try to mount configmap/sercet/vct to codeserver */}}
{{- if not (and (eq $objectData.shortName "codeserver") (mustHas $persistenceValues.type $codeServerIgnoredTypes)) -}}
{{- $volMount := (fromJson (include "tc.v1.common.lib.container.volumeMount.isSelected" (dict "persistenceName" $persistenceName "persistenceValues" $persistenceValues "objectData" $objectData))) -}}
{{- $volMount := (include "tc.v1.common.lib.container.volumeMount.isSelected" (dict
"rootCtx" $rootCtx "persistenceName" $persistenceName "persistenceValues" $persistenceValues "objectData" $objectData
)) | fromJson -}}
{{- if $volMount -}}
{{- $volMounts = mustAppend $volMounts $volMount -}}
{{- end -}}
@@ -69,9 +71,14 @@ objectData: The object data to be used to render the container.
{{- $persistenceName := .persistenceName -}}
{{- $persistenceValues := .persistenceValues -}}
{{- $objectData := .objectData -}}
{{- $rootCtx := .rootCtx -}}
{{/* Initialize from the default values */}}
{{- $volMount := dict -}}
{{- if eq $objectData.podType "StatefulSet" -}}
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $rootCtx -}}
{{- $persistenceName = printf "%s-%s" $fullname $persistenceName -}}
{{- end -}}
{{- $_ := set $volMount "name" $persistenceName -}}
{{- if eq $persistenceValues.type "device" -}} {{/* On devices use the hostPath as default if mountpath is not defined */}}
{{- $_ := set $volMount "mountPath" ($persistenceValues.mountPath | default $persistenceValues.hostPath | default "") -}}