Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
+ "github.com/docker/distribution/reference" |
|
| 9 | 10 |
"github.com/docker/docker/api" |
| 10 | 11 |
"github.com/docker/docker/api/types" |
| 11 | 12 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -115,7 +116,22 @@ func (c *containerContext) Image() string {
|
| 115 | 115 |
if trunc := stringid.TruncateID(c.c.ImageID); trunc == stringid.TruncateID(c.c.Image) {
|
| 116 | 116 |
return trunc |
| 117 | 117 |
} |
| 118 |
+ // truncate digest if no-trunc option was not selected |
|
| 119 |
+ ref, err := reference.ParseNormalizedNamed(c.c.Image) |
|
| 120 |
+ if err == nil {
|
|
| 121 |
+ if nt, ok := ref.(reference.NamedTagged); ok {
|
|
| 122 |
+ // case for when a tag is provided |
|
| 123 |
+ if namedTagged, err := reference.WithTag(reference.TrimNamed(nt), nt.Tag()); err == nil {
|
|
| 124 |
+ return reference.FamiliarString(namedTagged) |
|
| 125 |
+ } |
|
| 126 |
+ } else {
|
|
| 127 |
+ // case for when a tag is not provided |
|
| 128 |
+ named := reference.TrimNamed(ref) |
|
| 129 |
+ return reference.FamiliarString(named) |
|
| 130 |
+ } |
|
| 131 |
+ } |
|
| 118 | 132 |
} |
| 133 |
+ |
|
| 119 | 134 |
return c.c.Image |
| 120 | 135 |
} |
| 121 | 136 |
|