Prevent garm db passphrase regeneration on redeployment
This commit is contained in:
parent
8e6647a86f
commit
b46e1d03b5
2 changed files with 19 additions and 4 deletions
|
|
@ -44,10 +44,9 @@ Get Gitea token - either user-provided or generated
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "garm.dbPassphrase" -}}
|
{{- define "garm.dbPassphrase" -}}
|
||||||
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-config" ( include "garm.fullname" . )) -}}
|
{{- $secret := lookup "v1" "Secret" .Release.Namespace (printf "%s-db-credentials" ( include "garm.fullname" . )) -}}
|
||||||
{{- if and $secret ((fromToml (index $secret.data "config.toml" | b64dec)).database.passphrase) -}}
|
{{- if and $secret (index $secret.data "passphrase" | b64dec) -}}
|
||||||
{{- $another := fromToml (index $secret.data "config.toml" | b64dec) -}}
|
{{- (index $secret.data "passphrase" | b64dec) -}}
|
||||||
{{ $another.database.passphrase }}
|
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- include "garm.randomString" . -}}
|
{{- include "garm.randomString" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,22 @@ stringData:
|
||||||
GARM_URL: {{ printf "https://%s" (index .Values.ingress.hosts 0).host | quote }}
|
GARM_URL: {{ printf "https://%s" (index .Values.ingress.hosts 0).host | quote }}
|
||||||
GIT_URL: {{ .Values.credentials.gitea.url | quote }}
|
GIT_URL: {{ .Values.credentials.gitea.url | quote }}
|
||||||
---
|
---
|
||||||
|
{{- $secretName := printf "%s%s" (include "garm.fullname" .) "-db-credentials" -}}
|
||||||
|
{{- $secretExists := lookup "v1" "Secret" .Release.Namespace $secretName -}}
|
||||||
|
|
||||||
|
{{- if not $secretExists -}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ $secretName }}
|
||||||
|
namespace: {{ .Release.Namespace }}
|
||||||
|
annotations:
|
||||||
|
"helm.sh/hook": pre-install,pre-upgrade
|
||||||
|
"helm.sh/hook-weight": "-5"
|
||||||
|
stringData:
|
||||||
|
passphrase: {{- include "garm.randomString" . -}}
|
||||||
|
{{- end -}}
|
||||||
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue