helm: Values file key deletion doesn't work

I tried to use the feature to delete default keys (documented here) but it doesn’t work.

To test it I created a simple values.yaml file like this;

a: a
b: b
c: c

and a small template:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data: |
{{- range $key, $value := .Values }}
  {{ $key }} - {{ $value }}
{{- end }}

When I try to delete the “b” key like this helm install test-chart --debug --dry-run --set b=null I get this:

COMPUTED VALUES:
a: 1
b: "null"
c: 3

HOOKS:
MANIFEST:

---
# Source: test-chart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data: |
  a - 1
  b - null
  c - 3

I also tried grabbing the source code and looking at the values and I think I found what part of the problem is. In the “coalesceValues” method there is a check for value == nil (see here). According to the commit message it’s expecting the value to be nil at this point but what I found out is that the value is actually a string with the value “null”. So instead of deleting the key we actually end up using the key with a value of “null”

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 12
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@marespane I’m working on a series of patches that fix several bugs with the value merging behavior in pkg/chartutil

I’ve just hit this in both v2.9.1 and v2.10.0, this is still not working as described.

$ helm template --set controller.nodeSelector."node-role\.kubernetes\.io\/ingress"=null

Result:

      nodeSelector:
        node-role.kubernetes.io/ingress: null

I tied setting an empty string instead, similar issue:

$ helm template --set controller.nodeSelector."node-role\.kubernetes\.io\/ingress"=""

Result:

      nodeSelector:
        node-role.kubernetes.io/ingress: ""

Trying to do this for a key which is a table yields:

2018/11/14 21:15:52 warning: cannot overwrite table with non table for host (map[domain:vantiq.com hostname:<nil>])

I’m assuming it is the same root cause (null gets converted to a string, which of course is not a table), but just in case.

I’ve hit this bug as well.

I’ve hit this bug as well. Think that issue is in how to give it nil value, hope it will be fixed soon.