Skip to content

Commit

Permalink
use lookup to check if secret data exist
Browse files Browse the repository at this point in the history
  • Loading branch information
JorritSalverda committed Sep 8, 2021
1 parent 46fe31d commit 08dfbfc
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions helm/estafette-ci-api/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@ metadata:
labels:
{{- include "estafette-ci-api.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": "pre-install"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/resource-policy": keep
type: Opaque
data:
{{- $secret := lookup "v1" "Secret" .Release.Namespace (include "estafette-ci-api.fullname" .) | default dict -}}

{{- if .Values.secret.secretDecryptionKey }}
secretDecryptionKey: {{ .Values.secret.secretDecryptionKey | b64enc | quote }}
secretDecryptionKey: {{ .Values.secret.secretDecryptionKey | b64enc }}
{{- else if $secret }}
{{- if $secret.data.secretDecryptionKey }}
secretDecryptionKey: {{ $secret.data.secretDecryptionKey }}
{{- else }}
secretDecryptionKey: {{ randAlphaNum 32 | b64enc | quote }}
secretDecryptionKey: {{ randAlphaNum 32 | b64enc }}
{{- end }}
{{- else }}
secretDecryptionKey: {{ randAlphaNum 32 | b64enc }}
{{- end }}

{{- if .Values.secret.jwtKey }}
jwtKey: {{ .Values.secret.jwtKey | b64enc | quote }}
jwtKey: {{ .Values.secret.jwtKey | b64enc }}
{{- else if $secret }}
{{- if $secret.data.jwtKey }}
jwtKey: {{ $secret.data.secretDjwtKeyecryptionKey }}
{{- else }}
jwtKey: {{ randAlphaNum 32 | b64enc }}
{{- end }}
{{- else }}
jwtKey: {{ randAlphaNum 32 | b64enc | quote }}
jwtKey: {{ randAlphaNum 32 | b64enc }}
{{- end }}

{{- end }}

0 comments on commit 08dfbfc

Please sign in to comment.