gdcloud 主題格式

名稱

gdcloud topic formats - 資源格式的補充說明。

說明

許多 gdcloud CLI 指令會在成功時傳回資源清單。根據預設,這些內容會以標準輸出形式顯示。--format=NAME[PROJECTIONS] 標記可用來格式化預設輸出內容,並將其變更為更有意義的結果。

使用 --format 旗標變更指令的預設輸出格式。我們稍後會詳細說明資源格式。

使用投影列出資源中的資源鍵子集。

注意:如要參閱欄位清單,可以依各項資源排序及設定格式。您可以執行 list 指令,並將格式設為 yamljsoncsvtexttable。例如,假設使用者要求系統 將文字從英文翻譯成法文

gdcloud clusters list --format=yaml

格式

格式運算式可用於變更指令的預設輸出格式。您可以使用多種輸出格式,包括以易讀格式輸出,以及輸出機器可讀的格式。格式運算式包含兩個部分

名稱 名稱

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)"