ti fs-vault read-secret
使用所有者凭证或委派凭证读取完整的 Secret 或其中一个字段。
语法
ti fs-vault read-secret
--secret-name <string>
[--field <string>]
[--file-system-id <string>]
[--format <string>]
[--fs-token <string>]
[--help]
[--vault-token <string>]
[--version]
选项
--secret-name <string>:Vault Secret 名称。[必需]--field <string>:可选,要读取的字段名称。--file-system-id <string>:选择文件系统。你也可以设置TI_FS_FILE_SYSTEM_ID。--format <string>:读取输出格式:json、raw或env。[默认值:json]--fs-token <string>:设置所有者 Filesystem 访问令牌。如果省略,命令会使用TI_FS_TOKEN环境变量。如果两者都未提供,命令会使用为所选 Filesystem 本地存储的令牌。对于委派认证,请改用--vault-token或TI_VAULT_TOKEN。--help:显示帮助信息。--vault-token <string>:委派ti fs-vault令牌;建议优先使用TI_VAULT_TOKEN。--version:显示版本信息。
有关所有命令共享的选项,请参见全局选项。
示例
以原始文本形式读取一个 Secret 字段:
# Write only the selected field value for direct consumption by a process. ti fs-vault read-secret --file-system-id <file-system-id> --secret-name db-prod --field PASSWORD --format raw将字段格式化为环境变量赋值:
# Emit an exportable environment-variable representation of the field. ti fs-vault read-secret --file-system-id <file-system-id> --secret-name db-prod --field DB_URL --format env使用 Vault 委派令牌读取:
# Read the delegated token without echoing it or storing it in shell history. printf 'Delegated Vault token: ' >&2 read -r -s TI_VAULT_TOKEN printf '\n' >&2 export TI_VAULT_TOKEN # Access only the field allowed by the delegated token. ti fs-vault read-secret --file-system-id <file-system-id> --secret-name db-prod --field DB_URL --format raw unset TI_VAULT_TOKEN