{{- if .Values.upload.googlestoragebucket.usingGCPController }}
apiVersion: gcp.kiwigrid.com/v1beta1
kind: GcpServiceAccount
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
    app.kubernetes.io/name: {{ include "mysqldump.name" . }}
    helm.sh/chart: {{ include "mysqldump.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
  name: {{ template "mysqldump.fullname" . }}
spec:
  serviceAccountIdentifier: {{ template "mysqldump.serviceAccountName" . }}
  serviceAccountDescription: Service account for accessing a storage bucket for mysql backups
  secretName: {{ template "mysqldump.gcpsecretName" . }}
  bindings:
  - resource: buckets/{{ index (splitList "/" (.Values.upload.googlestoragebucket.bucketname | replace "gs://" "")) 0  }}
    roles:
    - roles/storage.objectAdmin
{{ end }}