{{- if not .Values.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "minio.secretName" . }}
  labels:
    app: {{ template "minio.name" . }}
    chart: {{ template "minio.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque
data:
  accesskey: {{ if .Values.accessKey }}{{ .Values.accessKey | toString | b64enc | quote }}{{ else }}{{ randAlphaNum 20 | b64enc | quote }}{{ end }}
  secretkey: {{ if .Values.secretKey }}{{ .Values.secretKey | toString | b64enc | quote }}{{ else }}{{ randAlphaNum 40 | b64enc | quote }}{{ end }}
{{- if and .Values.gcsgateway.enabled .Values.gcsgateway.gcsKeyJson }}
  gcs_key.json: {{ .Values.gcsgateway.gcsKeyJson | toString | b64enc }}
{{- end }}
{{- if .Values.s3gateway.enabled -}}
{{- if .Values.s3gateway.accessKey }}
  awsAccessKeyId: {{ .Values.s3gateway.accessKey | toString | b64enc | quote }}
{{- end }}
{{- if .Values.s3gateway.secretKey }}
  awsSecretAccessKey: {{ .Values.s3gateway.secretKey | toString | b64enc | quote }}
{{- end }}
{{- end }}
{{- if .Values.etcd.clientCert }}
  etcd_client_cert.pem: {{ .Values.etcd.clientCert | toString | b64enc | quote }}
{{- end }}
{{- if .Values.etcd.clientCertKey }}
  etcd_client_cert_key.pem: {{ .Values.etcd.clientCertKey | toString | b64enc | quote }}
{{- end }}
{{- end }}
