Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default template function treats 0 value as unspecified #13036

Open
Endevir opened this issue May 15, 2024 · 2 comments
Open

default template function treats 0 value as unspecified #13036

Endevir opened this issue May 15, 2024 · 2 comments

Comments

@Endevir
Copy link

Endevir commented May 15, 2024

Hi!
I've encountered an interesting problem with helm templating engine: default function treats 0 (integer) values as unspecified and uses $default parameter.


A small example:
Having single templating yaml and values:

template.yaml:

apiVersion: v1
kind: Something
metadata:
  name: {{ default 1 .Values.myvalue0 }}
  surname: {{ default 1 .Values.myvalue555 }}

values.yaml

myvalue0: 0
myvalue555: 555

Running helm template test test

Received output:

---
# Source: test/templates/template.yaml
apiVersion: v1
kind: Something
metadata:
  name: 1
  surname: 555

Expected output:

---
# Source: test/templates/template.yaml
apiVersion: v1
kind: Something
metadata:
  name: 0
  surname: 555

Seems like helm treats zero values as unspecified and replaces with first argument for default templating function, which is not expected behavior.


Output of helm version:

version.BuildInfo{Version:"v3.12.3", GitCommit:"3a31588ad33fe3b89af5a2a54ee1d25bfe6eaa5e", GitTreeState:"clean", GoVersion:"go1.20.7"}

Output of kubectl version:

k version                      (minikube/default)
Client Version: v1.28.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.4

Cloud Provider/Platform (AKS, GKE, Minikube etc.): Minikube (doesn't actually matter)

@Endevir Endevir changed the title default template function treats 0 value as "omitted" default template function treats 0 value as unspecified May 15, 2024
@yxxhero
Copy link
Member

yxxhero commented May 16, 2024

@yxxhero
Copy link
Member

yxxhero commented May 16, 2024

this is right behavor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants