kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.7k stars 2.22k forks source link

`add` works similarly `replace` #5684

Closed tebaly closed 1 month ago

tebaly commented 1 month ago

What happened?

- op: add
  path: /spec
  value: {}

Such a patch leads to replacement /spec with a {} object

What did you expect to happen?

Should be added if the path is missing. Don't replace an existing value

How can we reproduce it (as minimally and precisely as possible)?

kind: HorizontalPodAutoscaler
metadata:
  name: api
spec: 
  minReplicas: 1
---
kind: HorizontalPodAutoscaler
metadata:
  name: api
  labels: 
    add.spec: true

Expected output

kind: HorizontalPodAutoscaler
metadata:
  name: api
spec: 
  minReplicas: 1
---
kind: HorizontalPodAutoscaler
metadata:
  name: api
  labels: 
    add.spec: true
spec: {}

Actual output

kind: HorizontalPodAutoscaler
metadata:
  name: api
spec: {}
---
kind: HorizontalPodAutoscaler
metadata:
  name: api
  labels: 
    add.spec: true
spec: {}

Kustomize version

v5.3.0

Operating system

Linux

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
tebaly commented 1 month ago

https://datatracker.ietf.org/doc/html/rfc6902#section-4.1