11/11/2022

Handling nullable nested values - Helm

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. 👋

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

More about me ➡️

Contact Me

Name

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

Bootstrap Cloud-Native bootstrappers like Crossplane with K3d - Automation

I created a logo for the Crossplane Bootstrapper because all good projects deserve a logo. 😁 TL;DR ...

Popular Posts

Blog Archive