{{- if .Values.backup.enabled }}
{{- if and (.Values.backup.uploadProviders.google.enabled) (not .Values.backup.uploadProviders.google.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-backup-gcloud
  labels:
    {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{ .Values.backup.uploadProviders.google.secretKey }}: {{ .Values.backup.uploadProviders.google.secret | b64enc | quote }}
{{- end }}
---
{{ if and (.Values.backup.uploadProviders.azure.enabled) (not .Values.backup.uploadProviders.azure.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-backup-azure
  labels:
    {{- include "common.labels.standard" . | nindent 4 }}
type: Opaque
data:
  {{ .Values.backup.uploadProviders.azure.secretKey }}: {{ .Values.backup.uploadProviders.azure.secret | b64enc | quote }}
{{- end }}
---
{{ if and (.Values.backup.uploadProviders.aws.enabled) (not .Values.backup.uploadProviders.aws.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-backup-aws
  labels:
    {{- include "common.labels.standard" . | nindent 4 }}
type: Opaque
data:
  accessKeyID: {{ .Values.backup.uploadProviders.aws.accessKeyID | b64enc | quote }}
  secretAccessKey: {{ .Values.backup.uploadProviders.aws.secretAccessKey | b64enc | quote }}
  region: {{ .Values.backup.uploadProviders.aws.region | b64enc | quote }}
{{- end }}
{{- end }}
