what's the meaning of $_ in helm template
Asked Answered
D

1

5

I want to know what's the meaning of $_ in helm template.

I konw helm template is using go sprig template:

helm function_list

But where can I find go template grammar document?

Dobbs answered 1/11, 2022 at 3:33 Comment(1)
It should not have any predefined value, but be set somewhere in in your template.Gillie
U
9

$_ is a variable with the name _. The template grammar is described in the package documentation.

Because set function returns a value, the following template action emits undesired data to the output.

 {{set $myDict "name4" "value4"}}

The examples in Helm documentation use assignment to $_ to trap the output (assignments do not emit anything to the output).

 {{$_ := unset $myDict "name4"}}

A variable with any name can be used. The variable $_ is used by convention to indicate that the value is not used. This is somewhat similar to the use of the blank identifier in Go.

Underlinen answered 1/11, 2022 at 3:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.