kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

kustomize edit fix deletes trailing comments

Open exocode opened this issue 2 years ago • 13 comments

What happened?

running command kustomize edit fix changes

---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
bases:
  - ../../base
patchesStrategicMerge:
  - ./deployment.yaml
# resources:
# - ./ingress-t2.yaml
# - ./middleware-frontend-t2.yaml
# - ./middleware-backend-t2.yaml

to

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
resources:
- ../../base
patches:
- path: ./deployment.yaml

What did you expect to happen?

it should keep comments untouched

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

# kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
bases:
  - ../../base
patchesStrategicMerge:
  - ./deployment.yaml
# resources:
# - ./ingress-t2.yaml
# - ./middleware-frontend-t2.yaml
# - ./middleware-backend-t2.yaml

run

kustomize edit fix

Expected output

# kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
resources:
- ../../base
patches:
- path: ./deployment.yaml
# resources:
# - ./ingress-t2.yaml
# - ./middleware-frontend-t2.yaml
# - ./middleware-backend-t2.yaml

Actual output

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: demo
resources:
- ../../base
patches:
- path: ./deployment.yaml

Kustomize version

v5.0.1

Operating system

MacOS

exocode avatar May 03 '23 21:05 exocode

/triage accepted

ramessesii2 avatar May 09 '23 05:05 ramessesii2

@ramessesii2: The label triage/accepted cannot be applied. Only GitHub organization members can add the label.

In response to this:

/triage accepted

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar May 09 '23 05:05 k8s-ci-robot

I'd like to work on it if somebody could please assign it to me. cc @exocode

ramessesii2 avatar May 09 '23 05:05 ramessesii2

/triage accepted /kind bug

@ramessesii2 There is some comment-preservation related code in kyaml that you might find useful while you are trying to fix this. I believe there is literally a function you can use called CopyComments somewhere. Please feel free to reach out if you need more help. You can also assign yourself the issue by leaving a comment /assign.

natasha41575 avatar May 10 '23 16:05 natasha41575

/assign

Thanks @natasha41575, those are good pointers.

ramessesii2 avatar May 11 '23 12:05 ramessesii2

@ramessesii2 I've a hack code to tackle the issue at #5180. It would be great if you have any suggestions. :)

wingyplus avatar May 26 '23 03:05 wingyplus

Thanks @wingyplus for the PR, I've been rather busy with my work.

ramessesii2 avatar May 26 '23 16:05 ramessesii2

/assign

wingyplus avatar Jun 08 '23 05:06 wingyplus

Renamed the issue to clarify that kustomize edit fix does currently preserve comments, as demonstrated by tests in kustomize/commands/internal/kustfile. The command just doesn't preserve trailing comments.

annasong20 avatar Jun 23 '23 20:06 annasong20

This also happens when you have comments at the end of a line:

images:
- name: imageone
  newName: registry.jfrog.io/docker/imageone # {"$imagepolicy": "platform-flux-tenant-config:imageone:name"}
  newTag: craft-4-957db1b2-1689262100 # {"$imagepolicy": "platform-flux-tenant-config:imageone:tag"}

->

images:
- name: imageone
  newName: registry.jfrog.io/docker/imageone
  newTag: craft-4-957db1b2-1689262100

cdenneen avatar Aug 02 '23 20:08 cdenneen

/assign

adzshaf avatar Aug 24 '23 15:08 adzshaf

Hi @adzshaf, if you would like to take over this issue. I have a question that I cannot figure out in https://github.com/kubernetes-sigs/kustomize/pull/5180. Hope this could be help.

wingyplus avatar Aug 26 '23 01:08 wingyplus

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Aug 25 '24 01:08 k8s-triage-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Nov 23 '24 02:11 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Dec 23 '24 02:12 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Jan 22 '25 02:01 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Jan 22 '25 02:01 k8s-ci-robot