sprig icon indicating copy to clipboard operation
sprig copied to clipboard

`deepCopy`, will not override an integer value with the value `0`

Open cunningr opened this issue 3 years ago • 0 comments

This issue is ported over from helm issues but i am not sure if the issue I am seeing would be in https://github.com/imdario/mergo?

Output of helm version:

version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.18.1"}

Output of kubectl version:

N/A

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

CAPI/Openstack, vanilla k8s.

Issue:

When doing a deepCopy, it is not possible to override an integer value with the value 0. I am not sure if this is a bug or a know behaviour (but it is a little annoying :-)).

We can reproduce this in the helm playground

With values:

---
rolloutStrategy1:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 1
    maxSurge: 1

rolloutStrategy2:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 0
    maxSurge: 1

and template:

---
{{- $nodeGroup := deepCopy $.Values.rolloutStrategy1 | mustMerge $.Values.rolloutStrategy2 }}
{{ toYaml $nodeGroup }}

I would expect the values in rolloutStrategy2 to override the values in rolloutStrategy1, which they do, unless the value is a 0.

cunningr avatar Dec 12 '22 08:12 cunningr