{{- if and (or .Values.s3.accessKey .Values.s3.secretKey) (not (and .Values.s3.accessKey .Values.s3.secretKey)) -}}
{{ fail "S3: If providing credentials, accessKey and secretKey must be both set." }}
{{- end -}}

{{- if and .Values.s3.enabled .Values.s3.accessKey .Values.s3.secretKey }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "spinnaker.fullname" . }}-s3
  labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
    component: halyard
type: Opaque
data:
  accessKey: {{ .Values.s3.accessKey | b64enc | quote }}
  secretKey: {{ .Values.s3.secretKey | b64enc | quote }}
{{- end }}
