mirror of https://github.com/docker/cli.git
Suppressing image digest in docker ps
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
parent
325c8823bc
commit
9e78c9b063
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api"
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
@ -115,7 +116,22 @@ func (c *containerContext) Image() string {
|
||||||
if trunc := stringid.TruncateID(c.c.ImageID); trunc == stringid.TruncateID(c.c.Image) {
|
if trunc := stringid.TruncateID(c.c.ImageID); trunc == stringid.TruncateID(c.c.Image) {
|
||||||
return trunc
|
return trunc
|
||||||
}
|
}
|
||||||
|
// truncate digest if no-trunc option was not selected
|
||||||
|
ref, err := reference.ParseNormalizedNamed(c.c.Image)
|
||||||
|
if err == nil {
|
||||||
|
if nt, ok := ref.(reference.NamedTagged); ok {
|
||||||
|
// case for when a tag is provided
|
||||||
|
if namedTagged, err := reference.WithTag(reference.TrimNamed(nt), nt.Tag()); err == nil {
|
||||||
|
return reference.FamiliarString(namedTagged)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// case for when a tag is not provided
|
||||||
|
named := reference.TrimNamed(ref)
|
||||||
|
return reference.FamiliarString(named)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.c.Image
|
return c.c.Image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue