You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: charts/k8s-service/templates/_helpers.tpl
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -73,23 +73,28 @@ However, due to yaml/json limitations, all the Kubernetes resources require file
73
73
{{- end -}}
74
74
75
75
{{/*
76
-
Validate hostPaths for duplicate mount paths and host paths.
76
+
Validate hostPaths for required fields and duplicates.
77
77
*/}}
78
78
{{- define "k8s-service.validateHostPaths" -}}
79
79
{{- $mountPaths := dict -}}
80
80
{{- $hostPaths := dict -}}
81
81
{{- range $name, $value := .Values.hostPaths -}}
82
-
{{- if $value.mountPath -}}
83
-
{{- if hasKey $mountPaths $value.mountPath -}}
84
-
{{- fail (printf "Duplicate mountPath '%s' found in hostPaths: both '%s' and '%s' use the same mountPath" $value.mountPath (index $mountPaths $value.mountPath) $name) -}}
85
-
{{- end -}}
86
-
{{- $_ := set $mountPaths $value.mountPath $name -}}
82
+
{{- /* Validate required fields */ -}}
83
+
{{- if not $value.path -}}
84
+
{{- fail (printf "hostPaths.%s: 'path' is required but not provided" $name) -}}
87
85
{{- end -}}
88
-
{{- if $value.path -}}
89
-
{{- if hasKey $hostPaths $value.path -}}
90
-
{{- fail (printf "Duplicate host path '%s' found in hostPaths: both '%s' and '%s' use the same path" $value.path (index $hostPaths $value.path) $name) -}}
91
-
{{- end -}}
92
-
{{- $_ := set $hostPaths $value.path $name -}}
86
+
{{- if not $value.mountPath -}}
87
+
{{- fail (printf "hostPaths.%s: 'mountPath' is required but not provided" $name) -}}
93
88
{{- end -}}
89
+
{{- /* Check for duplicate mountPath */ -}}
90
+
{{- if hasKey $mountPaths $value.mountPath -}}
91
+
{{- fail (printf "Duplicate mountPath '%s' found in hostPaths: both '%s' and '%s' use the same mountPath" $value.mountPath (index $mountPaths $value.mountPath) $name) -}}
92
+
{{- end -}}
93
+
{{- $_ := set $mountPaths $value.mountPath $name -}}
94
+
{{- /* Check for duplicate host path */ -}}
95
+
{{- if hasKey $hostPaths $value.path -}}
96
+
{{- fail (printf "Duplicate host path '%s' found in hostPaths: both '%s' and '%s' use the same path" $value.path (index $hostPaths $value.path) $name) -}}
0 commit comments