{{- $runner := (.Values.runner | default dict) -}}
{{- $runnerMode := (index $runner "mode" | default "") -}}
{{- $kubeMode := (index $runner "kubernetesMode" | default dict) -}}
{{- $kubeDefaults := (index $kubeMode "default" | default true) -}}
{{- $kubeServiceAccountName := (index $kubeMode "serviceAccountName" | default "") -}}
{{- if and (eq $runnerMode "kubernetes") $kubeDefaults (empty $kubeServiceAccountName) }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ include "kube-mode-serviceaccount.name" . | quote }}
  namespace: {{ include "autoscaling-runner-set.namespace" . | quote }}
  labels:
    {{- include "kube-mode-serviceaccount.labels" . | nindent 4 }}
  annotations:
    {{- include "kube-mode-serviceaccount.annotations" . | nindent 4 }}
  finalizers:
    - actions.github.com/cleanup-protection
{{- end }}
