5

I am using Google Cloud SDK CLI (gcloud command), and the command is great! Although I'd like to output Google Compute Engine's instances list in JSON format (by running gcloud compute instances list --format json) and filter it using jq JSON processor, the command sometimes outputs a message below:

Updates are available for some Cloud SDK components.  To install
them, please run:
$ gcloud components update

I know the message is important, but I'd like to treat the JSON output as well-formed. Is there a way to suppress the message? Both -q and --verbosity none option didn't work.

yanana
  • 155
  • 7

1 Answers1

8

You can disable the update check with the following command:

gcloud config set component_manager/disable_update_check true 

However, your use case should still work with the update message. Are you actually seeing problems with the JSON parser? The expected behavior is that the JSON output goes to standard output and the update message goes to standard error.

$ gcloud compute instances list --format=json > stdout.log 2> stderr.log
$ cat stderr.log

Updates are available for some Cloud SDK components.  To install them, please run:
  $ gcloud components update

$ cat stdout.log
{
    // JSON here
    // ...
}

This will let you parse the JSON with an invocation like the following:

gcloud compute instances list --format=json | python -m json.tool # substitute your tool of choice here
Zachary Newman
  • 253
  • 1
  • 4