golang template - how are the semantics for default

9/27/2018

Looking at helm charts, there is often something like:

{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}

I could not find anything about the default function(?) in the template docs:

https://golang.org/pkg/text/template/

What is the semantics of it? Are there any kind of arguments possible?

-- ProfHase85
go
kubernetes-helm

1 Answer

9/27/2018

It comes from the library sprig, which is used by Helm. Quoting the docs:

default "foo" .Bar 

In the above, if .Bar evaluates to a non-empty value, it will be used. But if it is empty, foo will be returned instead.

-- bereal
Source: StackOverflow