{{- if and .Values.tailscale.loginServer (not .Values.headscale.create) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Values.tailscale.secret.name }}
  namespace: {{ include "nebulous.namespace" . }}
  labels:
    {{- include "common.labels" . | nindent 4 }}
type: Opaque
data:
  {{ .Values.tailscale.secret.keys.loginServer }}: {{ .Values.tailscale.loginServer | b64enc }}
  {{ .Values.tailscale.secret.keys.apiKey }}: {{ required ".Values.tailscale.apiKey is required" .Values.tailscale.apiKey | b64enc }}
  {{ .Values.tailscale.secret.keys.authKey }}: {{ required ".Values.tailscale.authKey is required" .Values.tailscale.authKey | b64enc }}
{{- end }}
