Building Google Cloud Platform Solutions
上QQ阅读APP看书,第一时间看更新

Modifying configuration properties

To see the current values of all configuration properties, you can run gcloud config list --all. Because configuration properties are stored as key-value pairs, you can also directly read them with gcloud config get-value <PROPERTY> and change them with gcloud config set <PROPERTY> <VALUE>. In cases where you no longer need a configuration property, or if you want to use the default value for a property, you can remove them with gcloud config unset <PROPERTY>. There are quite a few configuration properties available. The full list can be viewed in the command's help documentation with gcloud config --help.

When viewing the list of configuration properties, you'll notice that they are grouped into sets much like command groups in the gcloud tool. When modifying a property with set-value, you'll need to specify a property as part of a group in the format group/property. For example, to modify the default compute zone to us-central1-b, you would use gcloud config set-value compute/zone us-central1-b. If no group is specified, gcloud will attempt to set the property in the core group.

Many of the configuration property groups modify behavior for interacting with a specific Google Cloud product or service. Properties found in these groups commonly set a default value for API calls such as the default zone for Compute Engine mentioned earlier. Other property groups, including core, interactive, and proxy, are more general or relate to user experience. In both cases, configuration properties can often be overridden by passing a flag to a command. For example, while setting core/project is ideal for long-term use, users can also pass the --project global flag to any command to target a different project. This behavior is useful for quick on-off commands as well as cases where the default value should not be trusted (such as when running a script).