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

get-value matching nodes with having certain child nodes #19

Open
CodeCommander opened this issue Dec 31, 2015 · 1 comment
Open

get-value matching nodes with having certain child nodes #19

CodeCommander opened this issue Dec 31, 2015 · 1 comment

Comments

@CodeCommander
Copy link

Google Cloud outputs yaml like this for meta data:

commonInstanceMetadata:
  fingerprint: ..
  items:
  - key: SQL_INSTANCE_IP
    value: 123.45.6.78
  - key: SQL_INSTANCE_NAME
    value: database-server

Is there any way to use shyaml get-value to get the value of the "value" key on a node having a "key" matching a specified string? e.g. something like:

gcloud compute project-info describe | shyaml get-value commonInstanceMetadata.items[key=SQL_INSTANCE_IP].value

Right now I'm doing:

gcloud compute project-info describe | shyaml get-value commonInstanceMetadata.items | grep -A1 SQL_INSTANCE_IP | shyaml get-value 0.value

which seems to work, but I'm wondering if there is a better way without using grep?

@vaab
Copy link
Member

vaab commented Jan 11, 2016

That's a great idea, this is going towards xpath way, and you should know that parsing such a string is not trivial. Any PR is welcome though.

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

No branches or pull requests

2 participants