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:
Sebastiaan van Stijn
2025-07-14 19:51:30 +02:00
parent c69d8bde4a
commit e0f4bc699c
20 changed files with 86 additions and 34 deletions

View File

@ -27,7 +27,7 @@ func TestImageContext(t *testing.T) {
}{
{
imageCtx: imageContext{i: image.Summary{ID: imageID}, trunc: true},
expValue: stringid.TruncateID(imageID),
expValue: TruncateID(imageID),
call: ctx.ID,
},
{