gdcloud 主题格式

名称

gdcloud topic formats - 资源格式的补充帮助。

说明

许多 gdcloud CLI 命令会在成功时返回资源列表。默认情况下,它们会以整齐的格式显示在标准输出中。--format=NAME[PROJECTIONS] 标志可用于设置输出格式,并将默认输出更改为更有意义的结果。

使用 --format 标志可更改命令的默认输出格式。稍后将详细介绍资源格式。

使用投影列出资源中的部分资源键。

注意:如需查看字段列表,您可以按每个资源进行排序和格式化。您可以运行 list 命令,并将格式设置为 yamljsoncsvtexttable。例如,

gdcloud clusters list --format=yaml

格式

格式表达式用于更改命令的默认输出格式。系统提供了多种输出格式;有些用于以美观的方式输出人类可读的输出,有些用于返回机器可读的输出。格式表达式包含两个部分

名称 name

PROJECTIONS [ resource-key [, …] ]

NAME 是必需的,并且 PROJECTIONS 可以应用于 csvtexttable 格式。未知值会被静默忽略。每个 gdcloud list 命令都有一个默认的格式表达式。--format 标志可以更改或替换默认值。例如,

--format="table(clusterref.name,controlPlane.name,controlPlane.image)" 以表格格式列出了控制平面资源。

--format=json 以 JSON 格式列出资源。

可用的格式包括

## csv

Comma Separated Values (<https //www.ietf.org/rfc/rfc4180.txt>) with no keys. Use this format with a projection to define values to print.

## json

JSON (<https //www.json.org>), JavaScript Object Notation.

## table

Aligned left-adjusted columns and column headings are the disambiguated right hand components of the column keys in uppercase. For example, the projection keys `(first.name, last.name)` produce the default column heading `('FIRST.NAME', 'LAST.NAME')`. If the screen reader option is `True`, you might observe flattened list output instead of a table with columns. To turn it off, run  `gdcloud config set accessibility/screen_reader false`.

## text

A flattened tree. Each output line contains one `key` `value` pair. Use this format with a projection to define values to print.

## yaml

YAML (<https //www.yaml.org>), YAML ain't markup language.

示例

以 JSON 格式列出所有集群信息的状态

gdcloud clusters list --format=json

打印用户集群的集群参考详细信息

gdcloud clusters describe user-vm-1 --format="table(clusterref.name,clusterref.namespace)"