Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Default function evaluating the default value when the value provided is not omitted #12781

Description

@balmeida-nokia

Output of helm version: version.BuildInfo{Version:"v3.7.1+7.el8", GitCommit:"8f33223fe17957f11ba7a88b016bc860f034c4e6", GitTreeState:"clean", GoVersion:"go1.16.7"}

Output of kubectl version: Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.4",

Cloud Provider/Platform (AKS, GKE, Minikube etc.): ocp

values.yaml:

exampleKey: false

in template:

{{ default true .Values.exampleKey }}

I would expect this template to write false because false as a string is false and exampleKey is not omitted with its false value. However that block outputs true.

I read the manual that states:

This function allows you to specify a default value inside of the template, in case the value is omitted

image

In this case, the value is clearly not omitted and it's explicitly false. However, it's expected in case it's omitted, it becomes true (omitted, would mean the nil value, which is the value in go template when the value is non-existing in the dict).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions