mirror of
https://github.com/clearml/clearml-helm-charts
synced 2025-02-08 13:48:19 +00:00
46 lines
1.5 KiB
Smarty
46 lines
1.5 KiB
Smarty
|
{{/* vim: set filetype=mustache: */}}
|
||
|
{{/*
|
||
|
Print instructions to get a secret value.
|
||
|
Usage:
|
||
|
{{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }}
|
||
|
*/}}
|
||
|
{{- define "common.utils.secret.getvalue" -}}
|
||
|
{{- $varname := include "common.utils.fieldToEnvVar" . -}}
|
||
|
export {{ $varname }}=$(kubectl get secret --namespace {{ .context.Release.Namespace }} {{ .secret }} -o jsonpath="{.data.{{ .field }}}" | base64 --decode)
|
||
|
{{- end -}}
|
||
|
|
||
|
{{/*
|
||
|
Build env var name given a field
|
||
|
Usage:
|
||
|
{{ include "common.utils.fieldToEnvVar" dict "field" "my-password" }}
|
||
|
*/}}
|
||
|
{{- define "common.utils.fieldToEnvVar" -}}
|
||
|
{{- $fieldNameSplit := splitList "-" .field -}}
|
||
|
{{- $upperCaseFieldNameSplit := list -}}
|
||
|
|
||
|
{{- range $fieldNameSplit -}}
|
||
|
{{- $upperCaseFieldNameSplit = append $upperCaseFieldNameSplit ( upper . ) -}}
|
||
|
{{- end -}}
|
||
|
|
||
|
{{ join "_" $upperCaseFieldNameSplit }}
|
||
|
{{- end -}}
|
||
|
|
||
|
{{/*
|
||
|
Gets a value from .Values given
|
||
|
Usage:
|
||
|
{{ include "common.utils.getValueFromKey" (dict "key" "path.to.key" "context" $) }}
|
||
|
*/}}
|
||
|
{{- define "common.utils.getValueFromKey" -}}
|
||
|
{{- $splitKey := splitList "." .key -}}
|
||
|
{{- $value := "" -}}
|
||
|
{{- $latestObj := $.context.Values -}}
|
||
|
{{- range $splitKey -}}
|
||
|
{{- if not $latestObj -}}
|
||
|
{{- printf "please review the entire path of '%s' exists in values" $.key | fail -}}
|
||
|
{{- end -}}
|
||
|
{{- $value = ( index $latestObj . ) -}}
|
||
|
{{- $latestObj = $value -}}
|
||
|
{{- end -}}
|
||
|
{{- printf "%v" (default "" $value) -}}
|
||
|
{{- end -}}
|