Skip to content
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

Preserve comments in policy_yaml block #2055

Open
slonka opened this issue Oct 31, 2024 · 4 comments
Open

Preserve comments in policy_yaml block #2055

slonka opened this issue Oct 31, 2024 · 4 comments
Labels
kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it

Comments

@slonka
Copy link
Contributor

slonka commented Oct 31, 2024

Description

Now when we parse the yaml in policy_yaml it will remove the comments. One simple trick that we could do to preserve them would be to create a map like this:

(contents_of_line, line_number): comment

and after all the modifications are done reapply the comments by searching the map for the same line and a closeby line_number. E.g.:

image

would create a map like:

("          match: ", 20): "optional: if absent, all clusters will be patched"
...

and then we would reapply this comment somewhere near 20 line (let's say [15, 25]) to lines that match match:. WDYT?

@slonka slonka added triage/pending This issue will be looked at on the next triage meeting kind/improvement Improvement on an existing feature labels Oct 31, 2024
@lahabana
Copy link
Contributor

It would be good. I'm a little curious on the feasability. Also there are yaml parsers (yq is one of them) which preserves comments. Wondering if there is such a thing on ruby

@slonka
Copy link
Contributor Author

slonka commented Oct 31, 2024

Maybe https://github.com/jim80net/yq ?

@bartsmykla bartsmykla added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting labels Nov 4, 2024
@bartsmykla
Copy link
Contributor

triage: we should check if the builtin ruby YAML parser doesn't allow preserving comments

Copy link
Contributor

github-actions bot commented Feb 3, 2025

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 3, 2025
@lukidzi lukidzi removed the triage/stale Inactive for some time. It will be triaged again label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it
Projects
None yet
Development

No branches or pull requests

4 participants