0

I would like to create a map in value file and get the value depending of another variable.

For example :

resource[belgium] : 4G
resource[canada] : 4G

Then by passing the value belgium in environment variable COUNTRY, something like:

 {{ .Values.resource[$COUNTRY] }}

I don't find anything in the documentation.

Tx for help,

Gegko

Gegko
  • 15
  • 4
  • Helm templates can't access environment variables, only the Helm values structure (but consider the `helm install -f` or `--set` options to dynamically pass options to it). From there you can use the template `index` function, as [Access a map value using a variable key in a Go template](https://stackoverflow.com/questions/26152088/access-a-map-value-using-a-variable-key-in-a-go-template) or [Helm: Get value from a Map where the key is variable](https://stackoverflow.com/questions/59734551/helm-get-value-from-a-map-where-the-key-is-variable). – David Maze Jul 05 '22 at 01:46
  • I'd suggest avoiding the lookup in code and having a separate values file per environment, and then doing something like `helm install -f canada.yaml` to choose a specific set of configuration values. – David Maze Jul 05 '22 at 01:46
  • The issue with this is that we have a lot of countries on 3 differents environment that means like 60 configuration files. I will try the index solution ! Tx for your help ! – Gegko Jul 06 '22 at 13:43

0 Answers0