kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Retain initial document separator if present

Open AlessandroZanatta opened this issue 11 months ago • 4 comments

Eschewed features

  • [x] This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

kyaml is a great library that is used by many projects. Sequence indentation retention is a very useful feature when used to automatically update YAML files (e.g. on a repository). However, it is missing a (small) piece imo, that is, retaining the initial YAML document separator (---), if present.

Why is this needed?

In projects like ArgoCD image updater or FluxCD, kyaml is used to update the images by updates to the kustomization file. While sequence indentation is retained, the initial document separator is not, thus leading to (pointless) diffs (such as this on my repository). This may additionally conflict with linter rules enforced via GitHub actions, and so on.

Can you accomplish the motivating task without this feature, and if so, how?

As far as I can tell, the library does not offer a way to do this.

What other solutions have you considered?

It would be possible to patch the projects using kyaml to add the document separator (if and when needed), but in my opinion this fits better inside the library as an optional functionality.

Anything else we should know?

I'm open to implement this change myself!

A possible implementation could be a simple (optional) boolean flag on the kio readers and writers structs that allows to retain the initial document separator, if present in the parsed document, similarly to how sequence indentation is handled currently.

Let me know if this implementation idea may work (from the point of view of clients at least), and if a contribution to implement it is appreciated.

Feature ownership

  • [x] I am interested in contributing this feature myself! 🎉

AlessandroZanatta avatar Jan 18 '25 13:01 AlessandroZanatta

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 Apr 19 '25 22:04 k8s-triage-robot

/remove-lifecycle stale

stormqueen1990 avatar May 04 '25 23:05 stormqueen1990

/triage accepted

stormqueen1990 avatar May 19 '25 22:05 stormqueen1990