组织和项目是 Google Distributed Cloud (GDC) 气隙资源层次结构中的两个可用上下文。您可以使用 gdcloud CLI 属性在组织和项目之间切换。 您可以查看组织和项目的当前设置。
查看现有设置
初始化 gdcloud CLI 后,您可以使用以下命令查看组织和项目的现有设置。
列出有效 配置的 gdcloud CLI 属性:
gdcloud config list
打印组织控制台网址:
gdcloud config get organization_console_url
打印项目属性:
gdcloud config get project
打印可用区属性:
gdcloud config get core/zone
在上下文之间切换
如果您想切换到新的组织或项目上下文,可以在有效配置中或在另一个命名配置中设置属性。
在有效配置中设置属性
切换到新组织:
gdcloud config set organization_console_url ORGANIZATION_CONSOLE_URL
切换到新项目:
gdcloud config set project PROJECT_ID
切换到新可用区:
gdcloud config set core/zone ZONE_NAME
在新的命名配置中设置属性
假设您已创建新的命名配置 example,并已使用特定 https://console.example-org.com 和 example-project 对其进行设置:
gdcloud config configurations create example
gdcloud config set organization_console_url https://console.example-org.com
gdcloud config set project example-project
然后,您可以通过激活配置 example 来切换到使用此类上下文:
gdcloud config configurations activate example