feature: imagePullSecrets from string array. (#576)
* allow configuring imagePullSecrets from an array of strings in addition to the already supported array of maps
This commit is contained in:
parent
43656864c6
commit
64b4d88c72
7 changed files with 74 additions and 12 deletions
|
@ -623,3 +623,20 @@ Inject extra environment populated by secrets, if populated
|
|||
{{ "https" }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
imagePullSecrets generates pull secrets from either string or map values.
|
||||
A map value must be indexable by the key 'name'.
|
||||
*/}}
|
||||
{{- define "imagePullSecrets" -}}
|
||||
{{- with .Values.global.imagePullSecrets -}}
|
||||
imagePullSecrets:
|
||||
{{- range . -}}
|
||||
{{- if typeIs "string" . }}
|
||||
- name: {{ . }}
|
||||
{{- else if index . "name" }}
|
||||
- name: {{ .name }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -77,8 +77,5 @@ spec:
|
|||
{{- if .Values.csi.volumes }}
|
||||
{{- toYaml .Values.csi.volumes | nindent 8}}
|
||||
{{- end }}
|
||||
{{- if .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- include "imagePullSecrets" . | nindent 6 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -174,8 +174,5 @@ spec:
|
|||
secret:
|
||||
secretName: "{{ .Values.injector.certs.secretName }}"
|
||||
{{- end }}
|
||||
{{- if .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- include "imagePullSecrets" . | nindent 6 }}
|
||||
{{ end }}
|
||||
|
|
|
@ -202,10 +202,7 @@ spec:
|
|||
{{- if .Values.server.extraContainers }}
|
||||
{{ toYaml .Values.server.extraContainers | nindent 8}}
|
||||
{{- end }}
|
||||
{{- if .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- include "imagePullSecrets" . | nindent 6 }}
|
||||
{{ template "vault.volumeclaims" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
|
@ -72,6 +72,33 @@ load _helpers
|
|||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.imagePullSecrets' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '. | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "2" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[0].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[1].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "bar" ]
|
||||
}
|
||||
|
||||
@test "csi/daemonset: Custom imagePullSecrets - string array" {
|
||||
cd `chart_dir`
|
||||
local object=$(helm template \
|
||||
--show-only templates/csi-daemonset.yaml \
|
||||
--set "csi.enabled=true" \
|
||||
--set 'global.imagePullSecrets[0]=foo' \
|
||||
--set 'global.imagePullSecrets[1]=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.imagePullSecrets' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '. | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "2" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[0].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
|
|
@ -146,6 +146,32 @@ load _helpers
|
|||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.imagePullSecrets' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '. | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "2" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[0].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[1].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "bar" ]
|
||||
}
|
||||
|
||||
@test "server/standalone-StatefulSet: Custom imagePullSecrets - string array" {
|
||||
cd `chart_dir`
|
||||
local object=$(helm template \
|
||||
--show-only templates/server-statefulset.yaml \
|
||||
--set 'global.imagePullSecrets[0]=foo' \
|
||||
--set 'global.imagePullSecrets[1]=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.imagePullSecrets' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '. | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "2" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.[0].name' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
|
|
@ -5,6 +5,7 @@ global:
|
|||
# will enable or disable all the components within this chart by default.
|
||||
enabled: true
|
||||
# Image pull secret to use for registry authentication.
|
||||
# Alternatively, the value may be specified as an array of strings.
|
||||
imagePullSecrets: []
|
||||
# imagePullSecrets:
|
||||
# - name: image-pull-secret
|
||||
|
|
Loading…
Reference in a new issue