{{- if or (and .Values.aws.secretKey .Values.aws.accessKey) .Values.cloudflare.apiKey .Values.extraEnv -}}
apiVersion: v1
kind: Secret
metadata:
  labels: {{ include "external-dns.labels" . | indent 4 }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  name: {{ template "external-dns.fullname" . }}
type: Opaque
data:
{{- if eq .Values.provider "aws" }}
  credentials: {{ include "external-dns.aws-credentials" . | b64enc | quote }}
  config: {{ include "external-dns.aws-config" . | b64enc | quote }}
{{- end}}
{{- if .Values.cloudflare.apiKey }}
  cloudflare_api_key: {{ .Values.cloudflare.apiKey | b64enc | quote }}
{{- end }}
{{- range $key, $value := .Values.extraEnv }}
  {{ $key }}: {{ $value | b64enc | quote }}
{{- end }}
{{- end }}
