跳转至

CLI 参考

顶层命令

命令 说明
vault init 在当前目录生成 vault.json 骨架
vault install vault.json → 写 .vault/secrets.json + .env
vault sync 等价 install,覆盖刷新
vault check 关系自洽性校验
vault who-uses <slug> 反查哪些项目引用此 credential/resource

五层子命令(每层一致)

vault {person|platform|account|credential|resource} list   [--filters]
vault {...} show <slug>                                     [--json]
vault {...} add  <slug>                                     # 打开 $EDITOR
vault {...} edit <slug>                                     # 打开 $EDITOR
vault {...} rm   <slug> [-y]                                # 带确认删除

person

命令 选项 说明
person list --json 列所有 person
person show <slug> 看一个 person
person add <slug> 新建(natural_person / legal_entity)
person edit <slug> 修改
person rm <slug> -y 删除

platform

命令 选项 说明
platform list --category vendor\|government\|bank\|education\|certification\|self, --json 列 platform catalog
platform show <slug>
platform add/edit/rm

account

account slug 是 <platform>/<name>,如 aliyun/main

命令 选项
account list --platform <slug>, --owner <person-slug>, --json
account show <slug>
account add/edit/rm

credential

命令 选项
credential list --account <slug>, --kind <kind>, --json
credential show <slug> --unmask(明文), --field <name>(单字段), --json
credential add/edit/rm

resource

resource ref 是 <platform>/<type>/<id>,如 aliyun/ecs/i-bp17gxpssxlqi9ig7xxh

命令 选项
resource list --platform, --type, --account, --json
resource show <ref> --json
resource add/edit/rm

退出码

  • 0 = 成功
  • 1 = 业务错误(找不到 / 校验失败 / install 失败)
  • 2 = 用法错误(缺参数、枚举不匹配等,由 click 控制)

环境变量

变量 作用
VAULT_DATA_DIR 覆盖 <repo>/data 默认位置(测试 / 多仓)
EDITOR add / edit 用的编辑器