Quantcast
Channel: A Portal to a Portal
Viewing all articles
Browse latest Browse all 1850

Today I Learned - IBM Container Registry - Formatting the output ...

$
0
0

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: -

JQ vs jsonpath

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

The documentation covers the formatting options in WAAAAAY more detail: -


Viewing all articles
Browse latest Browse all 1850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>