compress namespaces from controller.workflowNamespaces and workflow.namespace into single loop iteration

Signed-off-by: reinvantveer <rein.van.t.veer@geodan.nl>
This commit is contained in:
reinvantveer 2021-07-12 14:15:50 +02:00
parent 1a2c4b6388
commit 424f1fc97f

View file

@ -11,40 +11,26 @@ metadata:
Cardinality-check the namespaces/namespace variables Cardinality-check the namespaces/namespace variables
This type check is done only once, here. It would be overkill to perform it for other RBAC resources as well. This type check is done only once, here. It would be overkill to perform it for other RBAC resources as well.
*/}} */}}
{{- if and .Values.controller.workflowNamespaces .Values.workflow.namespace }} {{- if and .Values.controller.workflowNamespaces .Values.workflow.namespace }}
{{- fail "Please set either controller.workflowNamespaces or workflow.namespace for the service account, not both" }} {{- fail "Please set either controller.workflowNamespaces or workflow.namespace for the service account, not both" }}
{{- end }} {{- end }}
{{- if .Values.controller.workflowNamespaces }} {{- /*
{{- /*
Type-check the namespaces variable for being a list ("slice") Type-check the namespaces variable for being a list ("slice")
This type check is done only once, here. It would be overkill to perform it for other RBAC resources as well. This type check is done only once, here. It would be overkill to perform it for other RBAC resources as well.
*/}} */}}
{{- if .Values.controller.workflowNamespaces }}
{{- if not ( kindIs "slice" .Values.controller.workflowNamespaces ) }} {{- if not ( kindIs "slice" .Values.controller.workflowNamespaces ) }}
{{- fail ( printf "workflow.namespaces is a slice, got %s %s" ( kindOf .Values.controller.workflowNamespaces ) .Values.controller.workflowNamespaces ) }} {{- fail ( printf "workflow.namespaces is a slice, got %s %s" ( kindOf .Values.controller.workflowNamespaces ) .Values.controller.workflowNamespaces ) }}
{{- end }} {{- end }}
{{- end }}
{{ $namespaces := .Values.controller.workflowNamespaces }} {{ range $namespace := append .Values.controller.workflowNamespaces .Values.workflow.namespace | compact | uniq }}
{{- range $namespaces }} {{ $namespace := . }}
{{ $namespace := . }} {{ include "sa-base" . }}
{{ include "sa-base" . }}
name: {{ $.Values.workflow.serviceAccount.name }} name: {{ $.Values.workflow.serviceAccount.name }}
namespace: {{ $namespace }} namespace: {{ $namespace }}
annotations:
{{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }}
{{- end }}
{{- else }}
{{ include "sa-base" . }}
name: {{ $.Values.workflow.serviceAccount.name }}
{{- if .Values.workflow.namespace }}
namespace: {{ .Values.workflow.namespace }}
{{- end }}
annotations: annotations:
{{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }}
{{- end }} {{- end }}
{{- end }} {{- end }}