Skip to content

Commit

Permalink
show concise image info for crictl ps
Browse files Browse the repository at this point in the history
fix #360
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
  • Loading branch information
yanxuean committed Aug 11, 2018
1 parent d2bc823 commit e8b6f38
Show file tree
Hide file tree
Showing 10 changed files with 1,217 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/crictl/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

units "github.com/docker/go-units"
godigest "github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"golang.org/x/net/context"
Expand Down Expand Up @@ -625,11 +626,17 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
ctm := units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago"
if !opts.verbose {
id := c.Id
image := c.Image.Image
if !opts.noTrunc {
id = getTruncatedID(id, "")

// Now c.Image.Image is imageID in kubelet.
if digest, err := godigest.Parse(image); err == nil {
image = getTruncatedID(digest.String(), string(digest.Algorithm())+":")
}
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\n",
id, c.Image.Image, ctm, convertContainerState(c.State), c.Metadata.Name, c.Metadata.Attempt)
id, image, ctm, convertContainerState(c.State), c.Metadata.Name, c.Metadata.Attempt)
continue
}

Expand Down
1 change: 1 addition & 0 deletions vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ github.com/modern-go/reflect2 05fbef0ca5da472bbf96c9322b84a53edc03c9fd
github.com/onsi/ginkgo 67b9df7f55fe1165fd9ad49aca7754cce01a42b8
github.com/onsi/gomega d59fa0ac68bb5dd932ee8d24eed631cdd519efc3
github.com/opencontainers/selinux 4a2974bf1ee960774ffd517717f1f45325af0206
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
github.com/pborman/uuid ca53cad383cad2479bbba7f7a1a05797ec1386e4
github.com/sirupsen/logrus 89742aefa4b206dcf400792f3bd35b542998eb3b
github.com/urfave/cli 8e01ec4cd3e2d84ab2fe90d8210528ffbb06d8ff
Expand Down
191 changes: 191 additions & 0 deletions vendor/github.com/opencontainers/go-digest/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e8b6f38

Please sign in to comment.