Skip to content

Commit

Permalink
CH-162 fix random values generation
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Nov 6, 2024
1 parent 6c85656 commit b27916f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions deployment-configuration/helm/templates/auto-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ metadata:
labels:
app: {{ .app.harness.deployment.name }}
type: Opaque
{{- $secret := (lookup "v1" "Secret" .root.Values.namespace $secret_name) }}
{{- if $secret }}
{{- $secret := (lookup "v1" "Secret" .root.Values.namespace $secret_name) }}
{{- if $secret }}
# secret already exists
{{- if not (compact (values .app.harness.secrets)) }}
# secret values are null, copy from the existing secret
data:
{{- range $k, $v := $secret.data }}
{{ $k }}: {{ $v }}
{{- end }}
{{- else }}
# there are non default values in values.yaml, use these
stringData:
{{- range $k, $v := .app.harness.secrets }}
{{ $k }}: {{ $v | default (randAlphaNum 20) }}
{{- end }}
{{- end }}
{{- else }}
{{- range $k, $v := .app.harness.secrets }}
{{- if $v }}
# Set secret value to value in values.yaml if specified
{{ $k }}: {{ $v }}
{{- else if not (hasKey $secret.data $k) }}
# Create a random secret value if not specified in values.yaml and is not already in the secret
{{ $k }}: {{ randAlphaNum 20 }}
{{- end}}
{{- end }}
{{- else }}
# secret doesn't exist
stringData:
{{- range $k, $v := .app.harness.secrets }}
Expand Down

0 comments on commit b27916f

Please sign in to comment.