{{- if or (and .Values.aws.secretKey .Values.aws.accessKey) .Values.cloudflare.apiKey .Values.digitalocean.apiToken (and .Values.infoblox.wapiUsername .Values.infoblox.wapiPassword) .Values.extraEnv .Values.google.serviceAccountKey -}}
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 and (eq .Values.provider "google") .Values.google.serviceAccountKey }}
  credentials.json: {{ .Values.google.serviceAccountKey | b64enc | quote }}
{{- end}}
{{- if .Values.cloudflare.apiKey }}
  cloudflare_api_key: {{ .Values.cloudflare.apiKey | b64enc | quote }}
{{- end }}
{{- if .Values.digitalocean.apiToken }}
  digitalocean_api_token: {{ .Values.digitalocean.apiToken | b64enc | quote }}
{{- end }}
{{- if and .Values.infoblox.wapiUsername .Values.infoblox.wapiPassword }}
  infoblox_wapi_username: {{ .Values.infoblox.wapiUsername | b64enc | quote }}
  infoblox_wapi_password: {{ .Values.infoblox.wapiPassword | b64enc | quote }}
{{- end }}

{{- range .Values.extraEnv }}
  {{- if .value }}
  {{ .name }}: {{ .value | b64enc | quote }}
  {{- end }}
{{- end }}
{{- end }}
