diff --git a/cmd/crictl/display.go b/cmd/crictl/display.go index bc80a0777e..239fc51f21 100644 --- a/cmd/crictl/display.go +++ b/cmd/crictl/display.go @@ -37,6 +37,7 @@ const ( columnNamespace = "NAMESPACE" columnSize = "SIZE" columnTag = "TAG" + columnPinned = "PINNED" columnDigest = "DIGEST" columnMemory = "MEM" columnInodes = "INODES" diff --git a/cmd/crictl/image.go b/cmd/crictl/image.go index 97abe0dab7..94416c706f 100644 --- a/cmd/crictl/image.go +++ b/cmd/crictl/image.go @@ -155,6 +155,10 @@ var listImageCommand = &cli.Command{ Name: "no-trunc", Usage: "Show output without truncating the ID", }, + &cli.BoolFlag{ + Name: "pinned", + Usage: "Show whether the image is pinned or not", + }, }, Action: func(c *cli.Context) error { if c.NArg() > 1 { @@ -182,15 +186,19 @@ var listImageCommand = &cli.Command{ // output in table format by default. display := newTableDisplay(20, 1, 3, ' ', 0) verbose := c.Bool("verbose") + showPinned := c.Bool("pinned") showDigest := c.Bool("digests") quiet := c.Bool("quiet") noTrunc := c.Bool("no-trunc") if !verbose && !quiet { + row := []string{columnImage, columnTag} + if showPinned { + row = append(row, columnPinned) + } if showDigest { - display.AddRow([]string{columnImage, columnTag, columnDigest, columnImageID, columnSize}) - } else { - display.AddRow([]string{columnImage, columnTag, columnImageID, columnSize}) + row = append(row, columnDigest) } + display.AddRow(append(row, columnImageID, columnSize)) } for _, image := range r.Images { if quiet { @@ -207,11 +215,14 @@ var listImageCommand = &cli.Command{ repoDigest = getTruncatedID(repoDigest, "sha256:") } for _, repoTagPair := range repoTagPairs { + row := []string{repoTagPair[0], repoTagPair[1]} + if showPinned { + row = append(row, fmt.Sprintf("%v", image.Pinned)) + } if showDigest { - display.AddRow([]string{repoTagPair[0], repoTagPair[1], repoDigest, id, size}) - } else { - display.AddRow([]string{repoTagPair[0], repoTagPair[1], id, size}) + row = append(row, repoDigest) } + display.AddRow(append(row, id, size)) } continue }