Having got into the use of JSON to format the output from various different IBM Cloud CLI tools, using jq and jsonpath as per this example: -
However, for reasons known to them, the Container Registry (CR) plugin uses a different mechanism to format output, namely Go templates.
This is well documented here: -
Formatting and filtering the CLI output for IBM Cloud Container Registry commands
So, as an example, if I want to look for images that are greater than 1,000,000 bytes ( 1 Mb ) and wish to display the repository, tag and security status, this is what I'd run: -
ic cr image-list --format "{{ if gt .Size 1000000 }}{{ .Repository }}:{{ .Tag }} {{ .SecurityStatus.Status }}{{end}}"
Similarly, if I want to list all images, regardless of size, but including the namespace: -
ic cr image-list --format "{{ .Repository }}:{{ .Tag }} {{ .Namespace }} {{ .SecurityStatus.Status }}"
No comments:
Post a Comment