Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call toYaml and exclude particular key?

Inside the template I have a fragment like this:

props: {{- toYaml .Values.myApp.container.props }}

currently props contains 4 children:

...
    container:
      props:
        a: ...
        b: ...
        c: ...
        d: ...

But I want to exclude c on the fly. Is there way to do it ?

like image 940
gstackoverflow Avatar asked Oct 21 '25 12:10

gstackoverflow


1 Answers

Helm includes a function on dictionaries called omit.

The omit function is similar to pick, except it returns a new dict with all the keys that do not match the given keys. Example:

$myDict := dict "name1" "value1" "name2" "value2" "name3" "value 3"
$new := omit $myDict "name1" "name3"

The above returns {name2: value2}

In your case this would mean:

props: {{ omit .Values.myApp.container.props "c" | toYaml }}
like image 124
Itay Grudev Avatar answered Oct 23 '25 08:10

Itay Grudev