{{- $sa := .Values.serviceAccount }}
{{- if $sa.create }}
{{- $ctx := dict "helm" . "appKey" "server" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $ns := include "vm.namespace" $ctx }}
apiVersion: v1
kind: ServiceAccount
metadata:
  {{- $_ := set $ctx "extraLabels" $sa.extraLabels }}
  labels: {{ include "vm.metaLabels" $ctx | nindent 4 }}
  {{- with $sa.annotations }}
  annotations: {{ toYaml . | nindent 4 }}
  {{- end }}
  name: {{ tpl ($sa.name | default $fullname) $ctx }}
  namespace: {{ $ns }}
{{- end }}
