-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from hansaya/main
Ability to add extra env variables
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{/* | ||
Environment variables used by containers. | ||
*/}} | ||
{{- define "env_vars" -}} | ||
{{- $values := .Values.extraEnv -}} | ||
{{- if hasKey . "ObjectValues" -}} | ||
{{- with .ObjectValues.env -}} | ||
{{- $values = . -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- with $values -}} | ||
{{- $result := list -}} | ||
{{- range $k, $v := . -}} | ||
{{- $name := $k -}} | ||
{{- $value := $v -}} | ||
{{- if kindIs "int" $name -}} | ||
{{- $name = required "environment variables as a list of maps require a name field" $value.name -}} | ||
{{- end -}} | ||
|
||
{{- if kindIs "map" $value -}} | ||
{{- if hasKey $value "value" -}} | ||
{{- $envValue := $value.value | toString -}} | ||
{{- $result = append $result (dict "name" $name "value" (tpl $envValue $)) -}} | ||
{{- else if hasKey $value "valueFrom" -}} | ||
{{- $result = append $result (dict "name" $name "valueFrom" $value.valueFrom) -}} | ||
{{- else -}} | ||
{{- $result = append $result (dict "name" $name "valueFrom" $value) -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- if not (kindIs "map" $value) -}} | ||
{{- if kindIs "string" $value -}} | ||
{{- $result = append $result (dict "name" $name "value" (tpl $value $)) -}} | ||
{{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}} | ||
{{- $result = append $result (dict "name" $name "value" ($value | toString)) -}} | ||
{{- else -}} | ||
{{- $result = append $result (dict "name" $name "value" $value) -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- toYaml (dict "env" $result) | nindent 0 -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters