diff --git a/charts/helmet/Chart.yaml b/charts/helmet/Chart.yaml index d828d8d..1924d3d 100644 --- a/charts/helmet/Chart.yaml +++ b/charts/helmet/Chart.yaml @@ -3,8 +3,8 @@ name: helmet description: Helmet is a library Helm Chart for grouping common logics. This chart is not deployable by itself. home: https://github.com/companyinfo/helm-charts/blob/main/charts/helmet type: library -version: "0.9.1" -appVersion: "0.9.1" +version: "0.10.0" +appVersion: "0.10.0" keywords: - common - helper diff --git a/charts/helmet/README.md b/charts/helmet/README.md index d96a1f3..ec31d0d 100644 --- a/charts/helmet/README.md +++ b/charts/helmet/README.md @@ -149,7 +149,7 @@ $ helm install nginx . | `initContainers` | Add additional init containers to the APP pod(s) | `[]` | | `command` | Override main container's command | `[]` | | `args` | Override main container's args | `[]` | -| `envVars` | Environment variables to be set on APP container | `[]` | +| `envVars` | Environment variables to be set on APP container | `{} or []` | | `envVarsConfigMap` | ConfigMap with environment variables | `""` | | `envVarsSecret` | Secret with environment variables | `""` | diff --git a/charts/helmet/examples/simple/Chart.lock b/charts/helmet/examples/simple/Chart.lock index 587173b..32acabc 100644 --- a/charts/helmet/examples/simple/Chart.lock +++ b/charts/helmet/examples/simple/Chart.lock @@ -1,6 +1,6 @@ dependencies: -- name: helmet - repository: https://nexus.ci.fdmg.org/repository/helm-repo - version: 0.4.5 -digest: sha256:53133e3ee01ee1612bfc649c43a7e0086794a8c509f070b1fe572d748f44a25c -generated: "2022-09-05T16:44:32.831090129+02:00" + - name: helmet + repository: https://companyinfo.github.io/helm-charts + version: 0.10.0 +digest: sha256:91533ef53882c22edf53d0c80fe48cccfc4dba0a0fbc536383d44fc914b1c8c8 +generated: "2023-09-27T17:51:06.480705091-07:00" diff --git a/charts/helmet/examples/simple/Chart.yaml b/charts/helmet/examples/simple/Chart.yaml index 57e3356..7e5196a 100644 --- a/charts/helmet/examples/simple/Chart.yaml +++ b/charts/helmet/examples/simple/Chart.yaml @@ -8,9 +8,10 @@ appVersion: "0.1.0" maintainers: - name: Company.info Developers url: https://company.info + dependencies: - name: helmet - version: 0.4.5 - repository: https://nexus.ci.fdmg.org/repository/helm-repo + version: ^0 + repository: https://companyinfo.github.io/helm-charts import-values: - defaults diff --git a/charts/helmet/templates/_deployment.yaml b/charts/helmet/templates/_deployment.yaml index 9bea2a2..d1e9c4e 100644 --- a/charts/helmet/templates/_deployment.yaml +++ b/charts/helmet/templates/_deployment.yaml @@ -63,7 +63,7 @@ spec: args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }} {{- end }} {{- if .Values.envVars }} - env: {{- include "common.tplvalues.render" (dict "value" .Values.envVars "context" $) | nindent 12 }} + env: {{- include "helmet.toEnvArray" (dict "envVars" .Values.envVars "context" $) | indent 12 }} {{- end }} {{- if or .Values.envVarsConfigMap .Values.envVarsSecret }} envFrom: diff --git a/charts/helmet/templates/_helpers.tpl b/charts/helmet/templates/_helpers.tpl index 805b5f9..2e401c8 100644 --- a/charts/helmet/templates/_helpers.tpl +++ b/charts/helmet/templates/_helpers.tpl @@ -8,3 +8,25 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + + +{{/* +Render an array of env variables. The input can be a map or a slice. +Values can be templates using the "common.tplvalues.render" helper, but changes to scope are not processed. +Usage: +{{ include "helmet.toEnvArray" ( dict "envVars" .Values.envVars "context" $ ) }} +*/}} +{{- define "helmet.toEnvArray" -}} +{{- if kindIs "map" .envVars }} +{{- range $key, $val := .envVars }} +- name: {{ $key }} +{{- if kindIs "string" $val }} + value: {{ include "common.tplvalues.render" (dict "value" $val "context" $.context) }} +{{- else if kindIs "map" $val }} +{{ include "common.tplvalues.render" (dict "value" (omit $val "name") "context" $.context) | indent 2 }} +{{- end -}} +{{- end -}} +{{- else if kindIs "slice" .envVars }} +{{ include "common.tplvalues.render" (dict "value" .envVars "context" $.context) }} +{{- end }} +{{- end -}} diff --git a/charts/helmet/values.yaml b/charts/helmet/values.yaml index 00c3992..ed25139 100644 --- a/charts/helmet/values.yaml +++ b/charts/helmet/values.yaml @@ -402,10 +402,12 @@ exports: ## @param envVars Environment variables to be set on APP container ## Example: ## envVars: - ## - name: FOO - ## value: "bar" + ## FOO: "foo" + ## BAZ: + ## valueFrom: + ## configMapRef: ... ## - envVars: [] + envVars: null ## @param envVarsConfigMap ConfigMap with environment variables ##