-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Casting yes/no to string does not produce a string value #341
Comments
I was reading up on yaml - the 1.1 spec allowed for those values - however that had a whole bunch of issues in different applications so in the 1.2 spec the dropped back to just true/false (https://yaml.org/spec/1.2/spec.html#id2803629, #go-yaml/yaml#214) |
For the record, v3.x of yq uses the v3 yaml parser, so this applies https://github.com/go-yaml/yaml/tree/v3#compatibility |
I see. Good to know. However, it seems that since there are still many apps that consume YAML 1.1 booleans (Kubernetes included, it seems, as that is the consumer in our case), the most compatible thing to do would be to output "yes", "no", etc with quotes when it is requested that they be strings ( |
yeah good idea - I'll put in a special condition for --tag '!!str' to force quotes around values. |
@mikefarah I just made a PR to go-yaml. If accepted, I think you may not need to add a condition. |
I think this will have a workaround in the upcoming --style flag, whereby you can force a double or single quotes with the tag flag. |
I tested it with yq 3.3.0, and that'll work for us. Thanks!
|
"yes" and "no" are boolean values in yaml when unquoted. If these strings are left unquoted by yq, then it's not possible to create the values "yes" and "no" as strings.
Here's the (large!) list of values that YAML treats as booleans:
https://yaml.org/type/bool.html
Actual
Taken from the doc on casting booleans, but replace "true" with "yes":
Expected
The text was updated successfully, but these errors were encountered: