首页 > 解决方案 > gcloud 具有不同配置的多个终端处于活动状态

问题描述

我使用不同的环境暂存和生产。通常我需要在两种环境中同时做事。每个环境都是一个 gcloud 配置。所以我总是在配置之间跳跃。

我想在不同的终端激活不同的配置,有什么办法吗?

当我运行下面的命令时,它会影响所有终端,有没有办法只影响当前终端?

gcloud config configurations activate <config-name>

任何解决方法的想法也会很有用

谢谢

标签: gcloudgcloud-cli

解决方案


根据gcloud help

GLOBAL FLAGS
     ...
     --configuration=CONFIGURATION
        The configuration to use for this command invocation. For more
        information on how to use configurations, run: gcloud topic
        configurations. You can also use the [CLOUDSDK_ACTIVE_CONFIG_NAME]
        environment variable to set the equivalent of this flag for a terminal
        session.

你可以在一个终端上运行

export CLOUDSDK_ACTIVE_CONFIG_NAME=config-name1

在另一个终端

export CLOUDSDK_ACTIVE_CONFIG_NAME=config-name2

希望这很有用。


推荐阅读