{{- if and (and .Values.cloudflare.account .Values.cloudflare.tunnelId .Values.cloudflare.secret) (not .Values.cloudflare.secretName) }}
# This credentials secret allows cloudflared to authenticate itself
# to the Cloudflare infrastructure.
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "cloudflare-tunnel.fullname" . }}
  labels:
    {{- include "cloudflare-tunnel.labels" . | nindent 4 }}
stringData:
  credentials.json: |-
    {
      "AccountTag": {{ .Values.cloudflare.account | quote }},
      "TunnelID": {{ .Values.cloudflare.tunnelId | quote }},
      "TunnelSecret": {{ .Values.cloudflare.secret | quote }}
    }
{{- end }}
