Merge branch 'main' into cnpg-versioning

This commit is contained in:
Stavros Kois
2024-03-10 02:25:59 +02:00
committed by GitHub
2 changed files with 55 additions and 0 deletions

View File

@@ -53,3 +53,44 @@ tests:
name: pvc-vol
persistentVolumeClaim:
claimName: some-existing-claim
# Failures
- it: should fail when DaemonSet and RWO volume from fallback
set:
fallbackDefaults:
accessModes:
- ReadWriteOnce
workload:
workload-name1:
enabled: true
primary: true
type: DaemonSet
podSpec: {}
persistence:
pvc-vol:
enabled: true
type: pvc
asserts:
- failedTemplate:
errorMessage: Expected [accessMode] to not be [ReadWriteOnce] when used on a [DaemonSet]
- it: should fail when DaemonSet and RWO volume from persistence
set:
fallbackDefaults:
accessModes:
- ReadWriteMany
workload:
workload-name1:
enabled: true
primary: true
type: DaemonSet
podSpec: {}
persistence:
pvc-vol:
enabled: true
accessModes:
- ReadWriteOnce
type: pvc
asserts:
- failedTemplate:
errorMessage: Expected [accessMode] to not be [ReadWriteOnce] when used on a [DaemonSet]

View File

@@ -51,6 +51,20 @@ objectData: The object data to be used to render the Pod.
{{/* Define the volume based on type */}}
{{- $type := ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
{{- if eq $objectData.type "DaemonSet" -}}
{{/* Only check accessModes if persistence is one of those types */}}
{{- $typesWithAccessMode := (list "pvc") -}}
{{- if (mustHas $type $typesWithAccessMode) -}}
{{- $modes := include "tc.v1.common.lib.pvc.accessModes" (dict "rootCtx" $rootCtx "objectData" $persistence "caller" "Volumes") | fromYamlArray -}}
{{- range $m := $modes -}}
{{- if eq $m "ReadWriteOnce" -}}
{{- fail "Expected [accessMode] to not be [ReadWriteOnce] when used on a [DaemonSet]" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if eq "pvc" $type -}}
{{- include "tc.v1.common.lib.pod.volume.pvc" (dict "rootCtx" $rootCtx "objectData" $persistence) | trim | nindent 0 -}}
{{- else if eq "hostPath" $type -}}