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

Maintain comments, formatting when dumping YAML #15

Open
jewzaam opened this issue Dec 10, 2015 · 4 comments
Open

Maintain comments, formatting when dumping YAML #15

jewzaam opened this issue Dec 10, 2015 · 4 comments

Comments

@jewzaam
Copy link

jewzaam commented Dec 10, 2015

Not everybody using the hiera data will be looking at monarch files. While it's good to have comments in the changeset we loose the ability to comment the hiera yaml. This can help folks understand why something was set etc.

@alechenninger
Copy link
Owner

This would be great, unfortunately it requires a YAML parser which parses extra metadata about the YAML document like whitespace and comments, and maintains that when dumping.

I considered using a YAML merge tool like https://github.com/geofffranks/spruce or something. This may do the trick. This sorts elements alphabetically too.

@alechenninger alechenninger changed the title Comments in hiera yaml files Maintain comments, formatting when dumping YAML Apr 2, 2016
@alechenninger
Copy link
Owner

I looked into this some more, there is not a good option for Java. There is a good option for Python though, so I may consider porting the library to Python, which has better support for CLI apps anyway: http://yaml.readthedocs.org/en/latest/overview.html

@alechenninger
Copy link
Owner

Note the above yaml library's preservation of formatting is not perfect:

This preservation is normally not broken unless you severely alter the structure of a component (delete a key in a dict, remove list entries). Reassigning values or replacing list items, etc., is fine.

@alechenninger
Copy link
Owner

#42 is implemented which helps. I think I can make this work for comments without too much effort, but not formatting. Comments are probably more important to maintain than formatting, though.

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

No branches or pull requests

2 participants