{{- if and (not .Values.config.existingSecret) (.Values.proxyVarsAsSecrets) }}
apiVersion: v1
kind: Secret
metadata:
{{- if .Values.config.annotations }}
  annotations:
{{ toYaml .Values.config.annotations | indent 4 }}
{{- end }}
  labels:
    app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
  name: {{ template "oauth2-proxy.fullname" . }}
  namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
data:
  cookie-secret: {{ tpl .Values.config.cookieSecret $ | b64enc | quote }}
  client-secret: {{ tpl .Values.config.clientSecret $ | b64enc | quote }}
  client-id: {{ tpl .Values.config.clientID $ | b64enc | quote }}
{{- end -}}
