Skip to content

Commit

Permalink
Fix secrets update
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Nov 18, 2024
1 parent c463081 commit a0302fc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions deployment-configuration/helm/templates/auto-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ type: Opaque
{{- $secret := (lookup "v1" "Secret" .root.Values.namespace $secret_name) }}
{{- if $secret }}
# secret already exists

stringData:
{{- range $k, $v := .app.harness.secrets }}
{{- if and $v (and (eq (typeOf $v) "string") (ne $v "?")) }}
{{- if and $v (eq (typeOf $v) "string") }}
{{- if (ne $v "?")}}
# Set secret value to value in values.yaml if specified
{{ $k }}: {{ $v }}
{{- else if and (eq (typeOf $v) "string") (or (eq $v "?") (not (hasKey $secret.data $k))) }}
# Create a random secret value if not specified in values.yaml if:
# 1. it is not set and it is not already in the deployed secret (static random secret)
# 2. its value is ? (dynamic random secret)
{{- else }}
# Refresh at any deployment for ? (pure random) value
{{ $k }}: {{ randAlphaNum 20 }}
{{- end }}
{{- else if not (hasKey $secret.data $k) }}
# Create a random secret value if not specified in values.yaml if
# it is not set and it is not already in the deployed secret (static random secret)
{{ $k }}: {{ randAlphaNum 20 }}
{{- end}}
{{- end }}
Expand Down

0 comments on commit a0302fc

Please sign in to comment.