From 424f1fc97f91e3d9ddae61fc4c96398f54450b0e Mon Sep 17 00:00:00 2001 From: reinvantveer Date: Mon, 12 Jul 2021 14:15:50 +0200 Subject: [PATCH] compress namespaces from controller.workflowNamespaces and workflow.namespace into single loop iteration Signed-off-by: reinvantveer --- .../templates/controller/workflow-sa.yaml | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/charts/argo-workflows/templates/controller/workflow-sa.yaml b/charts/argo-workflows/templates/controller/workflow-sa.yaml index f4428599..479df1c5 100644 --- a/charts/argo-workflows/templates/controller/workflow-sa.yaml +++ b/charts/argo-workflows/templates/controller/workflow-sa.yaml @@ -11,40 +11,26 @@ metadata: 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. */}} - {{- if and .Values.controller.workflowNamespaces .Values.workflow.namespace }} {{- fail "Please set either controller.workflowNamespaces or workflow.namespace for the service account, not both" }} {{- end }} - {{- if .Values.controller.workflowNamespaces }} - - {{- /* + {{- /* 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. */}} + {{- if .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 ) }} {{- end }} + {{- end }} - {{ $namespaces := .Values.controller.workflowNamespaces }} - {{- range $namespaces }} - {{ $namespace := . }} - {{ include "sa-base" . }} + {{ range $namespace := append .Values.controller.workflowNamespaces .Values.workflow.namespace | compact | uniq }} + {{ $namespace := . }} + {{ include "sa-base" . }} name: {{ $.Values.workflow.serviceAccount.name }} 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: {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} {{- end }} - {{- end }}