2025-12-01 15:43:13 +01:00
|
|
|
{{/*
|
|
|
|
|
Generate a random string for use as a secret
|
|
|
|
|
*/}}
|
|
|
|
|
{{- define "garm.randomString" -}}
|
|
|
|
|
{{- randAlphaNum 32 -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
|
Get admin password - either user-provided or generated
|
|
|
|
|
*/}}
|
|
|
|
|
{{- define "garm.adminPassword" -}}
|
|
|
|
|
{{ $credentials := (lookup "v1" "Secret" .Release.Namespace "garm-credentials") }}
|
|
|
|
|
{{- if hasKey $credentials "data" -}}
|
|
|
|
|
{{- if hasKey $credentials.data "GARM_ADMIN_PASSWORD" }}
|
|
|
|
|
{{- index $credentials.data "GARM_ADMIN_PASSWORD" | b64dec -}}
|
|
|
|
|
{{- else -}}
|
|
|
|
|
{{- "NO ADMIN PASSWORD" -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- else -}}
|
|
|
|
|
{{- include "garm.randomString" . -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
|
Get Gitea token - either user-provided or generated
|
|
|
|
|
*/}}
|
|
|
|
|
{{- define "garm.giteaToken" -}}
|
|
|
|
|
{{- if not .Values.credentials.giteaToken -}}
|
|
|
|
|
{{- include "garm.randomString" . -}}
|
|
|
|
|
{{- else -}}
|
|
|
|
|
{{- .Values.credentials.giteaToken -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
{{- define "garm.jwtSecret" -}}
|
2025-12-02 14:56:26 +01:00
|
|
|
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-config" ( include "garm.fullname" . )) -}}
|
|
|
|
|
{{- if and $secret ((fromToml (index $secret.data "config.toml" | b64dec)).jwt_auth.secret) -}}
|
|
|
|
|
{{- $another := fromToml (index $secret.data "config.toml" | b64dec) -}}
|
|
|
|
|
{{ $another.jwt_auth.secret }}
|
2025-12-01 15:43:13 +01:00
|
|
|
{{- else -}}
|
|
|
|
|
{{- include "garm.randomString" . -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
{{- define "garm.dbPassphrase" -}}
|
2025-12-22 10:29:24 +01:00
|
|
|
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-db-credentials" ( include "garm.fullname" . )) -}}
|
|
|
|
|
{{- if and $secret (index $secret.data "passphrase" | b64dec) -}}
|
|
|
|
|
{{- (index $secret.data "passphrase" | b64dec) -}}
|
2025-12-01 15:43:13 +01:00
|
|
|
{{- else -}}
|
|
|
|
|
{{- include "garm.randomString" . -}}
|
|
|
|
|
{{- end -}}
|
2025-12-02 14:56:26 +01:00
|
|
|
{{- end -}}
|