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

Why does yq output ... at the end? #109

Closed
rayzorben opened this issue Dec 30, 2020 · 6 comments
Closed

Why does yq output ... at the end? #109

rayzorben opened this issue Dec 30, 2020 · 6 comments

Comments

@rayzorben
Copy link

Example:

user:
  name: Ray

Output

~/source » yq -Y .user.name arch.yml                                       2 ↵ rayben@rayarchpad
Ray
...
@rayzorben
Copy link
Author

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

@kislyuk
Copy link
Owner

kislyuk commented Dec 30, 2020

Please see #104.

@kislyuk kislyuk closed this as completed Dec 30, 2020
@rayzorben
Copy link
Author

rayzorben commented Dec 30, 2020 via email

@kislyuk
Copy link
Owner

kislyuk commented Dec 30, 2020

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.

@kislyuk
Copy link
Owner

kislyuk commented Dec 30, 2020

It may be that in your last example there are missing newlines, though. I'll take a look at that (#110).

@rayzorben
Copy link
Author

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.

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

No branches or pull requests

2 participants