-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
In place write strips out comments #19
Comments
Apparently it also strips out both single
Command I used:
Let me know if you want a separate issue for this. |
yep this is because it parses the yaml file using https://godoc.org/gopkg.in/yaml.v2, and then spits it out again. This means it will not parse comments nor will it differentiate between those quotes if it is required to (for instance if the value is double quotes surrounded by singles ('"') ). |
Got it, thanks. |
@mikefarah is there a way to get yq to NOT strip quotes? I'm using yq for Docker Compose and I need to keep quotes around ports like this
|
Not at the moment - and given how it works with the yaml.v2 I'm not sure it can sorry :( There may be a workaround I'm not aware of, I'll reopen this issue. |
Ok. Thanks for reopening the issue. Here is the source I'm referencing https://docs.docker.com/compose/compose-file/
|
Is there any way to re-add the quotes via some command, though? |
Too bad it does this, I have to abandon using it because it removes comments. |
@IdanAdar Have you found the solution of re-adding the quotes? |
I have not. |
Can you suggest any work around or some other library? |
No. In my case it just happened to continue working even without the quotes. |
This might be useful... https://kev.inburke.com/kevin/more-comment-preserving-configuration-parsers/ I don't know Go, but someone wrote a library for it here: https://gist.github.com/kevinburke/07a21855df700b0acdea9e91c6fde7cf |
+1 for preserving comments. yq is a great tool, and we currently use it to automatically update our helm charts when a docker image changes As in most helm chart's values.yaml file, the optional values that have a complex format/complex objects are generally commented, therefore it is really required to keep the comments in order to inform the user on how to customize these values. I can think of a few workarounds to this using different files in our pipeline etc., but would be really appreciated if yq just preserved the comments |
https://ubuntu.com/blog/api-v3-of-the-yaml-package-for-go-is-available It looks like moving to the v3 parser is the solution. |
@shaleh reading the release details you linked to I can see that it will solve the comments issue, but I can't see anything about quoted values. Am I missing something? |
Yup - I've looked into the new library, looks really neat - but it requires significant rework of yq which I just don't have time for atm |
@andye2004 when I played with it you could preserve quotes |
any update on this issue? I am willing to collaborate if you will have me |
Following up on that: would really love to have comments preserved when updating files in place 👍 I am using |
Just released a new version of yaml that fixes this - it's a pretty significant update so it's still in beta: https://github.com/mikefarah/yq/releases/tag/3.0.0-beta |
Hi, looks great. I get the following: command: '"tox -vv -e${ENVLIST}"' (enclosed within single quotes) |
Yep - if you're wrapping with double quotes (so you can interpolate ENVLIST) then you'll need to escape the inner quotes.
will yield
That this therefore has the value "catthing" when reading the yaml. If you want a single pair of quotes:
Then at the moment v3 does not support this, instead it only quotes values when required. It could support an override by passing in a 'style' flag (https://godoc.org/gopkg.in/yaml.v3#Style). |
Sidenote:
and
Both effectively have the same values... |
Great, thanks for the quick and clear response.
…On Wed, Jan 22, 2020, 12:07 AM Mike Farah ***@***.***> wrote:
Sidenote:
services: catthing
and
services: "catthing"
Both effectively have the same values...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19?email_source=notifications&email_token=ABZIIDEOSR5MJAGHDQ5XQNTQ65W2JA5CNFSM4DX5UYK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJROMJY#issuecomment-576906791>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZIIDB5UOYS6QMKOX2DFXTQ65W2JANCNFSM4DX5UYKQ>
.
|
* add external_nodes to configyaml used by qctl, so qctl can interact with it, e.g. add, delete, ls * add support for listing the external nodes in a network: > qctl ls extnodes --all * add support for adding an external node: > qctl add extnode --enode="enode://[email protected]:7000" --tmurl=http://1.2.3.4:9000 --nodekeyaddr=0x1234334 * add support deleting external nodes: > qctl delete external-node * allow the external_node `Node_Acct_Addr` field to be set to a hex without quotes or a string hex in the qubernetes yaml. If it is set as a hex without quotes, the hex value will be converted to a BigNum, cover both cases in `istanbul-validator.toml.erb`. the yaml parser (https://godoc.org/gopkg.in/yaml.v2) used does not preserve double quotes around the hex mikefarah/yq#19
I'm still having this issue even on 4.44.2 . I have a command like But the quotes around dockerlimited do not get preserved. |
The CLI strips out comments given the following yaml file:
Using the following command for my test:
yaml w -i test.yml a.b.c[0] "test"
The text was updated successfully, but these errors were encountered: