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

Support quoting all strings in to yaml #9536

Open
jceb opened this issue Jun 26, 2023 · 2 comments
Open

Support quoting all strings in to yaml #9536

jceb opened this issue Jun 26, 2023 · 2 comments
Labels
enhancement New feature or request file-format Parsing/Writing of file formats/protocols needs-triage An issue that hasn't had any proper look

Comments

@jceb
Copy link

jceb commented Jun 26, 2023

Related problem

The to yaml command automatically unwraps scalar values. This causes an issue when working with CLI tools like kubeconform and datree that still support older YAML standards like version 1.1. In version 1.1 y and n were valid boolean values (https://yaml.org/type/bool.html). Nu's current behavior transforms strings like "n" and "y" into n and y that will triggers issues in 3rd party tools.

Describe the solution you'd like

I'd like to have a feature flag like -w that causes all string values to be wrapped in quotes to avoid any interpretation of these values by other YAML parsers.

Describe alternatives you've considered

As a more well-rounded solution, support for multiple YAML versions could be implemented for from yaml and to yaml, e.g. from yaml -v 1.2 | to yaml -v 1.1.

Additional context and details

No response

@jceb jceb added enhancement New feature or request needs-triage An issue that hasn't had any proper look labels Jun 26, 2023
@jceb
Copy link
Author

jceb commented Jun 26, 2023

As a workaround yq can be used: {a: "n", b: "y"} | to yaml | yq -o json -

My naive attempt to use JSON ({a: "n", b: "y"} | to json) as a subset of YAML has failed as there seem to be additional issues in to json in relation to octal values that I haven't investigated yet.

@sholderbach sholderbach added the file-format Parsing/Writing of file formats/protocols label Jun 26, 2023
@fdncred
Copy link
Collaborator

fdncred commented Jun 26, 2023

We'd probably accept a PR with a --quote/-q flag to do something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request file-format Parsing/Writing of file formats/protocols needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

No branches or pull requests

3 participants