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 and this is my "lite" technical blog!

I'm a passionate DevOps engineer, Cloud/Kubernetes specialist, Free/Open source geek, and an author.

I believe in self CI/CD (Continuous Improvements/Development), also that "the whole is greater than the sum of its parts".

DevOps transformation, automation, data, and metrics are my preferred areas. And I like to help both businesses and people to grow.

Latest Post

🔀Merger🔀, a schemaless strategic merge plugin - Kustomize

Kustomize is a great tool. I've been using Kustomize for almost 4 years and am happy with it. However, it's ...

Popular Posts

Blog Archive