Created
January 9, 2023 05:01
-
-
Save shubhamsre/068a2d6d408ad079c13406983255690b to your computer and use it in GitHub Desktop.
dynamic indexing helm
This file contains hidden or 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
##https://stackoverflow.com/questions/67380335/how-to-fetch-a-value-inside-an-array-using-helm-template | |
so the values.yaml looks something like | |
########values.yaml######## | |
ep: | |
staging: | |
ricochet: | |
ash: val1 | |
mini: val2 | |
pikachu: | |
ash: val3 | |
production: | |
ricochet: | |
ash: val4 | |
mini: val5 | |
pikachu: | |
ash: val6 | |
#####another-values.yaml######### | |
doraemon: | |
gadget1: ricochet | |
gadget2: ash | |
env: staging | |
##Endgoal: how to get val1 dynamically? | |
##this works, | |
####{{ (index .Values "ep" "staging" "ricochet" "ash") | |
##but how to derive staging from values.yaml itself? | |
##this fails, | |
{{ (index .Values "ep" .Values.doraemon.env .Values.doraemon.gadget1 .Values.doraemon.gadget2) }} |
For readability can use the following as well
{{- with $doraemon := .Values.doraemon -}}
{{- (index .Values "ep" $doraemon.env $doraemon.gadget1 $doraemon.gadget2) -}}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{{ (index .Values "ep" (index .Values.doraemon "env") (index .Values.doraemon "gadget1") (index .Values.doraemon "gadget2")) }}
This is how it works