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

Comments in the node line are not preserved #524

Closed
yuriylesyuk opened this issue Aug 29, 2020 · 4 comments
Closed

Comments in the node line are not preserved #524

yuriylesyuk opened this issue Aug 29, 2020 · 4 comments
Labels
Milestone

Comments

@yuriylesyuk
Copy link

Describe the bug
When updating/writing a node line with a comment, the comment at the end of the line is removed.

version of yq: 3.3.2
operating system: linux

Input Yaml

data.yml:

# things
a:
  b: # inventory
    c: fly # animal
    d: chair # furniture

Command
The command you ran:

yq w data.yaml a.b.c dog

Actual behavior

# things
a:
  b: # inventory
    c: dog
    d: chair # furniture

Expected behavior

# things
a:
  b: # inventory
    c: dog # animal
    d: chair # furniture
@olets
Copy link

olets commented Sep 5, 2020

Might not be an option for you, but it's possible to get close to your desired output by putting the comments on their own lines

# data.yaml
# things
a:
  # inventory
  b:
    # animal
    c: fly
    # furniture
    d: chair
% yq w git-replay.yaml a.b.c dog
# data.yaml
# things
a:
  # inventory
  b:
    # animal
    c: dog
    # furniture
    d: chair

@yuriylesyuk
Copy link
Author

Thank you for the suggestion. Unfortunately, it is not an option. The comments I need to work with are pseudo-comments that contain instructions for templating substitutions. Moving it at a separate line breaks templating tool.

For example, this is an example of such yaml:

https://github.com/GoogleCloudPlatform/anthos-service-mesh-packages/blob/master/asm/cluster/cluster.yaml

@mikefarah mikefarah added this to the 3.3.3 milestone Sep 7, 2020
@mikefarah
Copy link
Owner

Thanks for the clear bug, this should be straight forward to fix

@mikefarah
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants