Handling nullable nested values - Helm


I'd say this is one of the best tricks I've learned about Helm recently! For me, one of the most annoying things in Helm was that it's hard to handle nullable nested values!

For example, if you want to get the value of a nested key like .Values.foo.bar.baz, and if .Values.foo.bar is optional, you need to make sure that bar is not nil otherwise, Helm will throw an error.

Recently I just learned that you can use this syntax to call nested values even if their parent is nil!

{{ $bazValue := (((.Values.foo).bar).baz) }}

This way it doesn't matter if .Values.foo.bar is not defined or not, and you don't need to check the whole chain just to get the nested value.

All credit goes to Torrey on Stack Overflow. Check the link for more details about it how that works.

⎈Happy Helming!⎈

Powered by Blogger.

Hello, my name is Ahmed AbouZaid, I'm a passionate Tech Lead DevOps Engineer. 👋

With 16+ years of open-source contributions, 12+ years of professional hands-on experience in DevOps, and an M.Sc. in Data Engineering from Edinburgh Napier University (UK), I enjoy facilitating the growth of both businesses and individuals.

I specialize in Cloud-Native and Kubernetes. I'm also a Free/Open source geek and book author. My favorite topics are DevOps transformation, automation, data, and metrics.

Contact Me


Email *

Message *

Start Your DevOps Engineer Journey!

Start Your DevOps Engineer Journey!
Start your DevOps career for free the Agile way in 2024 with the Dynamic DevOps Roadmap ⭐

Latest Post

2023 Highlights

Image generated with Craiyon . Finally, 2023 is over! What a year! One more crazy year, but it was the culmination ...

Popular Posts

Blog Archive