4个版本 (破坏性更新)
| 0.6.0 | 2022年2月20日 |
|---|---|
| 0.5.0 | 2020年7月26日 |
| 0.4.0 | 2020年7月17日 |
| 0.3.0 | 2020年7月16日 |
| 0.1.0 |
|
#650 in 配置
38KB
671 行
gcloud-ctx (gctx)
一个用Rust编写的快速替代品,用于管理Google Cloud Platform gcloud配置
注意:该项目独立,与谷歌没有任何关联
安装
Windows
通过 scoop 安装
scoop bucket add adamrodger https://github.com/adamrodger/scoop-bucket
scoop install gctx
Mac/Linux
通过 brew 安装
brew install adamrodger/tap/gctx
预构建的二进制文件(Windows, Linux, Mac)
下载最新的二进制文件,解压并添加到您的 PATH。
从源代码
使用 rustup 获取Rust的最新稳定版本,并运行
cargo install gctx
用法
## show the current configuration (useful for adding to default prompt)
gctx current
gctx # shorthand, just omit current
## list all configurations
gctx list
## activate a different configuration
gctx my-config
gctx activate my-config # explicitly activate, e.g. if your configuration name clashes with a gctx command
gctx activate # if fzf is installed, you can omit the name and select from a list
## create (and optionally activate) a new configuration
gctx create my-config --project foo \
--account a.user@example.org \
--zone europe-west1-d \
--region europe-west1 \
--force \
--activate
## copy an existing configuration
gctx copy src-name dest-name --force --activate
## show the properties of a configuration (like gcloud config configurations describe)
gctx describe # defaults to the current configuration
gctx describe name # describe a named configuration
## rename a configuration
gctx rename old-name new-name
gctx rename --force old-name existing-name # use force to overwrite an existing configuration
## delete a configuration. note: you can't delete the active configuration
gctx delete my-config
## show help and usage
gctx --help
输出
gctx 默认通过终端能力自动检测并支持 NO_COLOR 和 CLICOLOR 标准,如 colored 包所提供。例如
# will have colors if the terminal supports them
gctx list
# force no colors on output
NO_COLOR=1 gctx list
CLICOLOR=0 gctx list
# force colors on output
CLICOLOR_FORCE=1 gctx list
动机
我经常使用多个GCP项目,它们有不同的设置(例如默认计算区域)。然而,标准的 gcloud 工具有两个主要问题
- 如果你经常切换,输入会相当多。当然,别名可以有所帮助,但...
gcloud初始化速度慢,使用起来很烦人,也不适合添加到默认提示
在使用 kubectx 解决类似问题,轻松在Kubernetes上下文之间切换后,我寻找了一个类似的工具,可以轻松在 gcloud 配置之间切换,但找不到任何东西。所以,在学习了 Rust 并对其印象深刻后,我认为这将是一个很好的入门项目。
目标
gctx 的目标是实现类似于 kubectx 的目标,例如
- 在不同
gcloud配置之间切换极快 - 跨平台
- 比输入
gcloud config configurations activate要短😄 - 使用
fzf进行模糊查找(如果已安装)
许可证
gctx根据MIT许可证条款分发
之前的gctx crate
请注意,0.3.0之前的gctx crate是之前作者的不相关作品,已被撤回并放弃。之前的作者很友好地将crate名称转给我,以便我可以重用它。再次感谢!
依赖项
约6-17MB
约223K SLoC