mcloud-variables

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cloud CLI: Variables Commands

Cloud CLI: 变量命令

Execute
mcloud variables
commands to inspect environment variables for Cloud environments.
执行
mcloud variables
命令,检查云环境的环境变量。

Constraints

约束条件

  • Never pass
    --reveal
    unless the user explicitly asks.
    Secret values appear in terminal scrollback, log aggregators, and process listings.
  • Looking up by key requires
    --project
    and
    --environment
    (or the equivalent in active context). Looking up by ID (
    var_...
    ) works without project/environment context.
  • 除非用户明确要求,否则请勿使用
    --reveal
    参数。
    敏感值会出现在终端回滚记录、日志聚合器和进程列表中。
  • 通过键查询时需要
    --project
    --environment
    参数(或使用当前上下文的对应值)。通过ID(格式为
    var_...
    )查询时无需项目/环境上下文。

Commands

命令

variables list

variables list

List all environment variables for a Cloud environment.
bash
mcloud variables list \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle> \
  --json
Options:
  • -o/--organization <id>
    — Organization ID (falls back to active context)
  • -p/--project <id-or-handle>
    — Project ID or handle (falls back to active context)
  • -e/--environment <handle>
    — Environment handle (falls back to active context)
  • --reveal
    — Print secret values in plaintext instead of masking (use only when explicitly asked)
  • --limit <1-500>
    — Max results (default:
    200
    )
  • --offset <number>
    — Pagination offset (default:
    0
    )
  • --json
    — Output as JSON
列出云环境的所有环境变量。
bash
mcloud variables list \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle> \
  --json
选项:
  • -o/--organization <id>
    — 组织ID(若未指定则使用当前上下文的组织)
  • -p/--project <id-or-handle>
    — 项目ID或标识(若未指定则使用当前上下文的项目)
  • -e/--environment <handle>
    — 环境标识(若未指定则使用当前上下文的环境)
  • --reveal
    — 以明文形式打印敏感值而非掩码(仅在用户明确要求时使用
  • --limit <1-500>
    — 最大结果数(默认值:
    200
  • --offset <number>
    — 分页偏移量(默认值:
    0
  • --json
    — 以JSON格式输出

variables get

variables get

Retrieve a single variable by its ID (
var_...
) or key.
bash
undefined
通过变量ID(格式为
var_...
)或键获取单个变量。
bash
undefined

By key (requires project + environment context)

By key (requires project + environment context)

mcloud variables get ADMIN_CORS
--organization <org-id>
--project <project-id-or-handle>
--environment <environment-handle>
--json
mcloud variables get ADMIN_CORS
--organization <org-id>
--project <project-id-or-handle>
--environment <environment-handle>
--json

By ID (works without project/environment context)

By ID (works without project/environment context)

mcloud variables get var_01XYZ --json

**Arguments:**
- `variable` — Variable ID (`var_...`) or key (required)

**Options:**
- `-o/--organization <id>`, `-p/--project <id-or-handle>`, `-e/--environment <handle>`
- `--reveal` — Print secret value in plaintext (**use only when explicitly asked**)
- `--json` — Output as JSON
mcloud variables get var_01XYZ --json

**参数:**
- `variable` — 变量ID(格式为`var_...`)或键(必填)

**选项:**
- `-o/--organization <id>`、`-p/--project <id-or-handle>`、`-e/--environment <handle>`
- `--reveal` — 以明文形式打印敏感值(**仅在用户明确要求时使用**)
- `--json` — 以JSON格式输出

Variable Fields (JSON)

变量字段(JSON格式)

FieldDescription
id
Variable ID (
var_...
)
key
Variable name (e.g.
ADMIN_CORS
)
value
Variable value (masked if
is_secret
and
--reveal
not passed)
is_secret
Whether the variable is treated as a secret
is_build
Available at build time
is_runtime
Available at runtime
entity_id
The environment ID this variable belongs to
字段描述
id
变量ID(格式为
var_...
key
变量名称(例如
ADMIN_CORS
value
变量值(若
is_secret
为真且未使用
--reveal
参数则显示为掩码)
is_secret
该变量是否被视为敏感值
is_build
是否在构建阶段可用
is_runtime
是否在运行阶段可用
entity_id
该变量所属的环境ID

Examples

示例

bash
undefined
bash
undefined

List all variables for the active environment

List all variables for the active environment

mcloud variables list --json
mcloud variables list --json

Get a variable by key (with active context)

Get a variable by key (with active context)

mcloud variables get DATABASE_URL --json
mcloud variables get DATABASE_URL --json

Get a variable by ID (no env context needed)

Get a variable by ID (no env context needed)

mcloud variables get var_01XYZ --json
mcloud variables get var_01XYZ --json

Only reveal secrets when user explicitly asks

Only reveal secrets when user explicitly asks

mcloud variables get STRIPE_SECRET_KEY --reveal --json | jq -r '.value'
mcloud variables get STRIPE_SECRET_KEY --reveal --json | jq -r '.value'

Export all variables to a .env file (user must explicitly request --reveal)

Export all variables to a .env file (user must explicitly request --reveal)

mcloud variables list --reveal --json
| jq -r '.[] | "(.key)=(.value)"' \
.env
mcloud variables list --reveal --json
| jq -r '.[] | "(.key)=(.value)"' \
.env

List only runtime variables

List only runtime variables

mcloud variables list --json | jq '[.[] | select(.is_runtime == true)]'
mcloud variables list --json | jq '[.[] | select(.is_runtime == true)]'

Check if a specific variable exists

Check if a specific variable exists

mcloud variables list --json | jq '.[] | select(.key == "REDIS_URL")'
undefined
mcloud variables list --json | jq '.[] | select(.key == "REDIS_URL")'
undefined