Search code examples
gcloud

Automate gcloud components update


How can I update the gcloud components programmatically within a shell script?

Calling gcloud components update requires an user entry, e.g.:

$ gcloud components update

The following components will be installed:
--------------------------------------------
| kubectl (Linux, x86_64) | 1.0.1 | 4.5 MB |
--------------------------------------------

For the latest release notes, please visit:
  https://dl.google.com/dl/cloudsdk/release/RELEASE_NOTES
Do you want to continue (Y/n)? 

I can't find an argument for gcloud to enforce the update.


Solution

  • You're looking for the --quiet flag.

    From gcloud --help:

     --quiet, -q
        Disable all interactive prompts when running gcloud commands. If input
        is required, defaults will be used, or an error will be raised.
    

    This is generally a flag you'll want for non-interactive contexts.

    You may also set the CLOUDSDK_CORE_DISABLE_PROMPTS environment variable to a non-empty value:

    export CLOUDSDK_CORE_DISABLE_PROMPTS=1
    gcloud components update # This works for all gcloud commands