diff --git a/library/common-test/tests/volumeClaimTemplate/vct_data_test.yaml b/library/common-test/tests/volumeClaimTemplate/vct_data_test.yaml index b6f44428..26641d19 100644 --- a/library/common-test/tests/volumeClaimTemplate/vct_data_test.yaml +++ b/library/common-test/tests/volumeClaimTemplate/vct_data_test.yaml @@ -39,7 +39,7 @@ tests: path: spec.volumeClaimTemplates[0].spec.resources.requests.storage value: 100Gi - documentIndex: *statefulSetDoc - isNull: + notExists: path: spec.volumeClaimTemplates[0].spec.storageClassName - it: should create vct with accessModes set as string @@ -67,7 +67,35 @@ tests: value: - ReadWriteMany - - it: should create pvc with accessModes set as list + - it: should create vct with changed fallback accessModes + set: + fallbackDefaults: + accessModes: + - ReadWriteMany + - ReadWriteOnce + persistence: + my-volume1: + enabled: true + type: vct + mountPath: /some/path + workload: + main: + enabled: true + primary: true + type: StatefulSet + podSpec: {} + asserts: + - documentIndex: *statefulSetDoc + isKind: + of: StatefulSet + - documentIndex: *statefulSetDoc + equal: + path: spec.volumeClaimTemplates[0].spec.accessModes + value: + - ReadWriteMany + - ReadWriteOnce + + - it: should create vct with accessModes set as list set: some_mode: ReadWriteMany persistence: @@ -95,7 +123,7 @@ tests: - ReadWriteMany - ReadWriteOnce - - it: should create pvc with size set + - it: should create vct with size set set: persistence: my-volume1: @@ -118,6 +146,30 @@ tests: path: spec.volumeClaimTemplates[0].spec.resources.requests.storage value: 20Gi + - it: should create vct with size set from tpl + set: + some_size: 40Gi + persistence: + my-volume1: + enabled: true + type: vct + mountPath: /some/path + size: "{{ .Values.some_size }}" + workload: + main: + enabled: true + primary: true + type: StatefulSet + podSpec: {} + asserts: + - documentIndex: *statefulSetDoc + isKind: + of: StatefulSet + - documentIndex: *statefulSetDoc + equal: + path: spec.volumeClaimTemplates[0].spec.resources.requests.storage + value: 40Gi + - it: should create vct with storageClass set "-" set: some_storage_class: "-" diff --git a/library/common/templates/class/cnpg/_cluster.tpl b/library/common/templates/class/cnpg/_cluster.tpl index 38104434..24426528 100644 --- a/library/common/templates/class/cnpg/_cluster.tpl +++ b/library/common/templates/class/cnpg/_cluster.tpl @@ -133,7 +133,6 @@ {{- end -}} {{- include "tc.v1.common.lib.util.verifycrd" (dict "rootCtx" $rootCtx "crd" "clusters.postgresql.cnpg.io" "missing" "CloudNative-PG") }} - --- apiVersion: postgresql.cnpg.io/v1 kind: Cluster diff --git a/library/common/templates/lib/storage/_volumeClaimTemplates.tpl b/library/common/templates/lib/storage/_volumeClaimTemplates.tpl index a24c3f36..5de62ad5 100644 --- a/library/common/templates/lib/storage/_volumeClaimTemplates.tpl +++ b/library/common/templates/lib/storage/_volumeClaimTemplates.tpl @@ -14,7 +14,7 @@ objectData: The object data to be used to render the Pod. "name" $name "caller" "Volume Claim Templates" "key" "persistence")) -}} - {{- if and (eq $enabled "true") (eq $vctValues.type "vct") -}} + {{- if and (eq $enabled "true") (eq $vctValues.type "vct") -}} {{- $vct := (mustDeepCopy $vctValues) -}} {{- $selected := false -}} @@ -42,13 +42,13 @@ objectData: The object data to be used to render the Pod. {{- $vctSize := $rootCtx.Values.fallbackDefaults.vctSize -}} {{- with $vct.size -}} {{- $vctSize = tpl . $rootCtx -}} - {{- end }} - {{- $_ := set $vct "size" $vctSize }} + {{- end -}} + {{- $_ := set $vct "size" $vctSize -}} {{- $vctAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}} {{- with $vct.accessModes -}} - {{- $vctAccessModes = $vct.accessModes -}} - {{- end }} + {{- $vctAccessModes = . -}} + {{- end -}} {{- $_ := set $vct "accessModes" $vctAccessModes }} - metadata: name: {{ include "tc.v1.common.lib.storage.pvc.name" (dict "rootCtx" $rootCtx "objectName" $vct.shortName "objectData" $vct) }}