{{- if .Values.Master.UseSecurity }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "jenkins.fullname" . }}
  labels:
    app: {{ template "jenkins.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  {{ if .Values.Master.AdminPassword }}
  jenkins-admin-password: {{ .Values.Master.AdminPassword | b64enc | quote }}
  {{ else }}
  jenkins-admin-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{ end }}
  {{ if and (.Values.Master.JCasC.enabled) (.Values.Master.Sidecars.configAutoReload.enabled) }}
  {{ if not .Values.Master.OwnSshKey }}
  {{ ( include "jenkins.gen-key" . ) }}
  {{ end }}
  {{ end }}
  jenkins-admin-user: {{ .Values.Master.AdminUser | b64enc | quote }}
{{- end }}