Closed rayzorben closed 3 years ago
Similarly, yq -y with some expressions puts -
at the beginning:
user:
name: Ray
Output of yq -y '..' file.yml
user:
name: Ray
---
name: Ray
--- Ray
...
But this one is really odd:
yq -Y '.. | tostring | startswith("!secret")' file.yml
outputs:
~/source » yq -Y '.. | tostring | startswith("!secret")' arch.yml rayben@rayarchpad
false
--- false
--- false
--- true
--- false
--- false
--- false
Please see #104.
Any idea on the second issue though or are they related and will both be fixed at the same time?
On Wed, Dec 30, 2020, 9:23 AM Andrey Kislyuk notifications@github.com wrote:
Please see #104 https://github.com/kislyuk/yq/issues/104.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kislyuk/yq/issues/109#issuecomment-752697120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3BD2TYSHAIYEOW5TTRXT3SXNOYDANCNFSM4VOAKLEQ .
That is a different issue, actually. You asked yq to translate a stream of multiple JSON documents back into YAML. But in YAML, unlike JSON, there is no unambiguous way to distinguish between a document boundary and a continuation of the existing document. So you will see PyYAML emit document separators (---
) in this case. Like #104, it's not a bug but an artifact of YAML/PyYAML's behavior, but unlike #104, I don't think there's anything expected in the future to control this behavior. To avoid it, you can just not use -y
/-Y
.
It may be that in your last example there are missing newlines, though. I'll take a look at that (#110).
Thanks, I guess what I am looking for may not be possible at this time (or have to use sed/grep/etc):
I want to take the following:
user:
password: !secret U4e80asdfnkjlasdf832r/u0q80sa
name: ray
...
And I want to say 'are there any values in this document (one or more) that contain the tag !secret
(which I know is a yaml thing and not a json thing).
And then I want to say
cat file.yml | yq '.user.password | tags'
> would return !secret
cat file.yml | yq .user.password
> would return U4e80asdfnkjlasdf832r/u0q80sa
That way I know what I am reading is an encrypted value.
Example:
Output