Skip to content

Commit

Permalink
Randomize pass if value is empty. Override if secret is specified
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Rigby <scott@r6by.com>
  • Loading branch information
scottrigby committed Jan 25, 2024
1 parent ba818ba commit 8bbf403
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
13 changes: 13 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Expand the name of the chart.
{{- end }}
{{- end }}

{{/*
Get the admin password value or a randomly generated password.
Note adminPassword is deprecated, and will be removed in a future version.
*/}}
{{- define "mission-control.admin.password" -}}
{{- if .Values.admin.password -}}
{{ .Values.admin.password -}}
{{- else if .Values.adminPassword -}}
{{ .Values.adminPassword -}}
{{- else -}}
{{ randAlphaNum 10 }}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
Expand Down
10 changes: 9 additions & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ spec:
secretKeyRef:
name: {{ .Values.db.jwtSecretKeyRef.name }}
key: {{ .Values.db.jwtSecretKeyRef.key }}
{{- if ne .Values.admin.existingSecret "" }}
- name: ADMIN_PASSWORD
value: {{ .Values.adminPassword }}
valueFrom:
secretKeyRef:
name: {{ .Values.admin.existingSecret }}
key: admin-password
{{- else }}
- name: ADMIN_PASSWORD
value: {{ include "mission-control.admin.password" . }}
{{- end }}
envFrom:
- secretRef:
name: {{ .Values.smtp.secretRef.name }}
Expand Down
13 changes: 12 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ smtp:
# SMTP_PORT: <port>
# SMTP_USER: <user>
# SMTP_PASSWORD: <password>
adminPassword: admin
# DEPRECATED - adminPassword is deprecated, and will be removed in a future version.
# adminPassword: ""
admin:
# If you leave this empty, and do not override with admin.existingSecret, a
# random password will be generated for you.
password: ""
# Specifying an existing secret name will override the admin.password.
# The secret key must be "admin-password"
# For example, to create from a file:
# echo -n 'S!B\*d$zDsb=' > ./admin-password.txt
# kubectl create secret generic admin-password-secret --from-file=admin-password.txt
existingSecret: ""
canary-checker:
image:
type: full
Expand Down

0 comments on commit 8bbf403

Please sign in to comment.