Open CodeCommander opened 8 years ago
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?
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.
xpath
Google Cloud outputs yaml like this for meta data:
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:
Right now I'm doing:
which seems to work, but I'm wondering if there is a better way without using grep?