Skip to content

Commit

Permalink
CH-162 fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Nov 22, 2024
1 parent 8ea73a8 commit c4989d4
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions deployment-configuration/helm/templates/auto-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,35 @@ metadata:
labels:
app: {{ .app.harness.deployment.name }}
type: Opaque
{{- $secret := (lookup "v1" "Secret" .root.Values.namespace $secret_name) }}
{{- if $secret }}
# secret already exists
{{ $secret := (lookup "v1" "Secret" .root.Values.namespace $secret_name) }}
{{/*- $secret := dict "data" (dict "test" "test") */}}
stringData:
{{- if $secret }}
{{- range $k, $v := .app.harness.secrets }}
{{- if and $v (eq (typeOf $v) "string") }}
{{- if (ne $v "?")}}
# Set secret value to value in values.yaml if specified
{{ $k }}: {{ $v }}
{{- else }}
# Refresh at any deployment for ? (pure random) value
{{ $k }}: {{ randAlphaNum 20 }}
{{- end }}
{{- if $v }}
{{- if eq (typeOf $v) "string" }}
{{- if ne $v "?" }}
{{/* Set secret value to value in values.yaml if specified */}}
{{ $k }}: {{ $v | quote }}
{{- else }}
{{/* Refresh at any deployment for ? (pure random) value */}}
{{ $k }}: {{ randAlphaNum 20 | quote }}
{{- end }}
{{- end }}
{{- else if eq (typeOf $secret.data) "map" }}
{{- 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 }}
{{/* 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 | quote }}
{{- end}}
{{- else }}
failsafe: check your values file
{{/* if it's not set and it's not ?, ignore */}}
{{- end }}
{{- end }}
{{- else }}
# secret doesn't exist
stringData:
{{- range $k, $v := .app.harness.secrets }}
{{ $k }}: {{ $v | default (randAlphaNum 20) }}
{{- end }}
{{- range $k, $v := .app.harness.secrets }}
{{ $k }}: {{ $v | default (randAlphaNum 20) | quote }}
{{- end }}
{{- end }}
---
{{- end }}
{{- range $app := .Values.apps }}
Expand Down

0 comments on commit c4989d4

Please sign in to comment.