-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Strategic merge patches should retain existing null values in targets #4628
Comments
If I understand the example correctly, the key will the null value is dropped when the strategic merge patch is applied, but it is retained if the resource is output as-is. I think this isn't a bug--if you ask Kustomize to apply the strategic merge patch, it will attempt to merge in the key with the null value as part of that process, i.e. delete it. |
An explicit |
Here is the expected output:
|
When you apply a merge patch to an object, the null value has a special meaning, specifically, delete the key/map in question. It's equivalent to the What is the type of |
It's a somewhat common pattern in helm charts. There's a |
I found this in the docs?
Which mentions only the src part (Is this what. you were referring too?) Does the element of least surprise have any effect here? It's more intuitive that everything under |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
I spoke to @apelisse from SIG API Machinery about this, and we discussed three other sources of precedent for what to do here:
I consider these precedents sufficient evidence to warrant changing Kustomize's behaviour. /retitle Strategic merge patches should retain existing null values in targets |
null
value is inconsistently removed
@KnVerey, with the proposed change in behavior, will a null value for a field in a patch still delete the corresponding field that's present in the target? |
Yes, it is unambiguous that that behaviour is correct. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Should we keep this open? |
Yes, we ended up agreeing that it should be changed, and it hasn't been worked on yet. /lifecycle frozen |
Reproduction steps are below. In the case
no-bug
, you can seereplicaCount: null
applied in the output. In the casehas-bug
, you can seereplicaCount: null
is missing. The only difference is the patch value.Reproduction steps
Directory structure.
Kustomize output
original:
has-bug:
no-bug:
Expected output of
has-bug
above:The text was updated successfully, but these errors were encountered: