{{- if .Values.s3.enabled -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "backupRestore.s3SecretName" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "backupRestore.labels" . | nindent 4 }}
type: Opaque
stringData:
  {{- with .Values.s3 }}
  {{- if .credentialSecretName }}
  credentialSecretName: {{ .credentialSecretName }} 
  credentialSecretNamespace: {{ required "When providing a Secret containing S3 credentials, a valid .Values.credentialSecretNamespace must be provided" .credentialSecretNamespace }}
  {{- end }}
  {{- if .region }}
  region: {{ .region | quote }}
  {{- end }}
  bucketName: {{ required "A valid .Values.bucketName is required for configuring S3 compatible storage as the default backup storage location" .bucketName | quote }}
  {{- if .folder }}
  folder: {{ .folder | quote }}
  {{- end }}
  endpoint: {{ required "A valid .Values.endpoint is required for configuring S3 compatible storage as the default backup storage location" .endpoint | quote }}
  {{- if .endpointCA }} 
  endpointCA: {{ .endpointCA }} 
  {{- end }}
  {{- if .insecureTLSSkipVerify }}
  insecureTLSSkipVerify: {{ .insecureTLSSkipVerify | quote }}
  {{- end }}
  {{- if .clientConfig }}
  clientConfig: {{ .clientConfig | toJson | quote }}
  {{- end }}
  {{- end }}
{{ end }}
