Skip to content

Commit

Permalink
add --pinned flag for ctr images
Browse files Browse the repository at this point in the history
Signed-off-by: Iceber Gu <[email protected]>
  • Loading branch information
Iceber committed Aug 21, 2023
1 parent 25ae10a commit 89b5d79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/crictl/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
columnNamespace = "NAMESPACE"
columnSize = "SIZE"
columnTag = "TAG"
columnPinned = "PINNED"
columnDigest = "DIGEST"
columnMemory = "MEM"
columnInodes = "INODES"
Expand Down
23 changes: 17 additions & 6 deletions cmd/crictl/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 89b5d79

Please sign in to comment.