diff --git a/charts/argo-workflows/templates/controller/workflow-role.yaml b/charts/argo-workflows/templates/controller/workflow-role.yaml index 5f84b38d..fc1f372f 100644 --- a/charts/argo-workflows/templates/controller/workflow-role.yaml +++ b/charts/argo-workflows/templates/controller/workflow-role.yaml @@ -3,11 +3,11 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - {{- end }} +{{- end }} - {{/* workflow-role-rules are defined separately so they can be inserted after templating the metadata */}} +{{/* workflow-role-rules are defined separately so they can be inserted after templating the metadata */}} - {{- define "workflow-role-rules" }} +{{- define "workflow-role-rules" }} rules: - apiGroups: - "" @@ -24,26 +24,27 @@ rules: verbs: - get - watch - {{- end }} +{{- end }} - {{- if .Values.workflow.rbac.create -}} +{{- if .Values.workflow.rbac.create -}} - {{- if .Values.workflow.namespaces }} - {{- range .Values.workflow.namespaces}} - {{ $namespace := . }} - {{- include "workflow-role-base" . }} - name: {{ template "argo-workflows.fullname" $ }}-workflow - namespace: {{ $namespace }} - {{- include "workflow-role-rules" . }} + {{- if .Values.workflow.namespaces }} + {{- range .Values.workflow.namespaces}} + {{ $namespace := . }} + {{- include "workflow-role-base" . }} + name: {{ template "argo-workflows.fullname" $ }}-workflow + namespace: {{ $namespace }} + {{- include "workflow-role-rules" . }} {{- end }} - {{- else }} + {{- else }} + {{- include "workflow-role-base" . }} - name: {{ template "argo-workflows.fullname" $ }}-workflow + name: {{ template "argo-workflows.fullname" $ }}-workflow {{- if .Values.workflow.namespace }} - namespace: {{ .Values.workflow.namespace }} + namespace: {{ .Values.workflow.namespace }} {{- end }} {{- include "workflow-role-rules" . }} {{- end }} - {{- end }} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/charts/argo-workflows/templates/controller/workflow-sa.yaml b/charts/argo-workflows/templates/controller/workflow-sa.yaml index 613b73b2..78f9d1a4 100644 --- a/charts/argo-workflows/templates/controller/workflow-sa.yaml +++ b/charts/argo-workflows/templates/controller/workflow-sa.yaml @@ -3,9 +3,9 @@ apiVersion: v1 kind: ServiceAccount metadata: - {{- end }} +{{- end }} - {{- if .Values.workflow.serviceAccount.create -}} +{{- if .Values.workflow.serviceAccount.create -}} {{- /* Cardinality-check the namespaces/namespace variables @@ -13,44 +13,44 @@ metadata: */}} {{- if and .Values.workflow.namespaces .Values.workflow.namespace }} - {{- fail "Please set either workflow.namespaces or workflow.namespace for the service account, not both" }} + {{- fail "Please set either workflow.namespaces or workflow.namespace for the service account, not both" }} {{- end }} {{- if and ( not .Values.workflow.namespace ) ( not .Values.workflow.namespaces ) }} - {{- fail "Please set either workflow.namespaces or workflow.namespace" }} + {{- fail "Please set either workflow.namespaces or workflow.namespace" }} {{- end }} {{- if .Values.workflow.namespaces }} - {{- /* + {{- /* 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 not ( kindIs "slice" .Values.workflow.namespaces ) }} - {{- fail ( printf "workflow.namespaces is a slice, got %s %s" ( kindOf .Values.workflow.namespaces ) .Values.workflow.namespaces ) }} - {{- end }} + {{- if not ( kindIs "slice" .Values.workflow.namespaces ) }} + {{- fail ( printf "workflow.namespaces is a slice, got %s %s" ( kindOf .Values.workflow.namespaces ) .Values.workflow.namespaces ) }} + {{- end }} - {{ $namespaces := .Values.workflow.namespaces }} - {{- range $namespaces }} - {{ $namespace := . }} - {{ include "sa-base" . }} + {{ $namespaces := .Values.workflow.namespaces }} + {{- range $namespaces }} + {{ $namespace := . }} + {{ include "sa-base" . }} name: {{ $.Values.workflow.serviceAccount.name }} namespace: {{ $namespace }} annotations: - {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} - {{- end }} + {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} + {{- end }} {{- else }} - {{- $namespaces := tuple .Values.workflow.namespace }} - {{- range $namespaces }} - {{- $namespace := . }} - {{ include "sa-base" . }} + {{- $namespaces := tuple .Values.workflow.namespace }} + {{- range $namespaces }} + {{- $namespace := . }} + {{ include "sa-base" . }} name: {{ $.Values.workflow.serviceAccount.name }} namespace: {{ $namespace }} annotations: - {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} - {{- end }} - {{- end }} + {{- toYaml $.Values.workflow.serviceAccount.annotations | nindent 4 }} + {{- end }} + {{- end }} - {{- end }} +{{- end }}