Skip to content

remove uses of github.com/docker/docker/pkg/stringid#6180

Merged
thaJeztah merged 2 commits intodocker:masterfrom
thaJeztah:truncate_id
Jul 15, 2025
Merged

remove uses of github.com/docker/docker/pkg/stringid#6180
thaJeztah merged 2 commits intodocker:masterfrom
thaJeztah:truncate_id

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jul 14, 2025

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.

remove uses of pkg/stringid.GenerateRandomID()

This utility was only used for testing, and to generate a random
suffix for Dockerfiles. As we don't need the same contract as
pkg/stringid.GenerateRandomID() (not allow all-numeric IDs as they
would not be usable for hostnames), we can use a local test-utility,
and local implementation for the random suffix instead.

- How to verify it

- Human readable description for the release notes

Go SDK: cli/command/formatter: add `TrunateID()` utility as alternative for `github.com/docker/docker/pkg/stringid.TrunateID()`

- A picture of a cute animal (not mandatory but encouraged)

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 <[email protected]>
This utility was only used for testing, and to generate a random
suffix for Dockerfiles. As we don't need the same contract as
pkg/stringid.GenerateRandomID() (not allow all-numeric IDs as they
would not be usable for hostnames), we can use a local test-utility,
and local implementation for the random suffix instead.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added this to the 28.3.3 milestone Jul 14, 2025
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code impact/changelog kind/enhancement area/go-sdk Changes affecting the Go SDK impact/go-sdk Noteworthy (compatibility changes) in the Go SDK labels Jul 14, 2025
@codecov-commenter
Copy link

@thaJeztah thaJeztah requested review from Benehiko and vvoland July 14, 2025 18:40
@thaJeztah thaJeztah merged commit 7d574b8 into docker:master Jul 15, 2025
123 of 130 checks passed
@thaJeztah thaJeztah deleted the truncate_id branch July 15, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/go-sdk Changes affecting the Go SDK impact/changelog impact/go-sdk Noteworthy (compatibility changes) in the Go SDK kind/enhancement kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants