cli/command/formatter: add TrunateID utility
We were depending on pkg/stringid to truncate IDs for presentation. While traditionally, we used a fixed length for "truncated" IDs, this is not a strict requirement (any ID-prefix should work, but conflicts may happen on shorter IDs). This patch adds a local `TruncateID()` utility in the formatter package; it's currently using the same implementation and length as the `stringid.TruncateID` function, but may diverge in future. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
units "github.com/docker/go-units"
|
||||
)
|
||||
|
||||
@ -216,7 +215,7 @@ func (c *imageContext) MarshalJSON() ([]byte, error) {
|
||||
|
||||
func (c *imageContext) ID() string {
|
||||
if c.trunc {
|
||||
return stringid.TruncateID(c.i.ID)
|
||||
return TruncateID(c.i.ID)
|
||||
}
|
||||
return c.i.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user