File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,17 @@ const (
1212 fullLen = 64
1313)
1414
15- // TruncateID returns a shorthand version of a string identifier for convenience.
16- // A collision with other shorthands is very unlikely, but possible.
17- // In case of a collision a lookup with TruncIndex.Get() will fail, and the caller
18- // will need to use a longer prefix, or the full-length Id.
15+ // TruncateID returns a shorthand version of a string identifier for presentation.
16+ // For convenience, it accepts both digests ("sha256:xxxx") and IDs without an
17+ // algorithm prefix. It truncates the algorithm (if any) before truncating the
18+ // ID. The length of the truncated ID is currently fixed, but users should make
19+ // no assumptions of this to not change; it is merely a prefix of the ID that
20+ // provides enough uniqueness for common scenarios.
21+ //
22+ // Truncated IDs ("ID-prefixes") usually can be used to uniquely identify an
23+ // object (such as a container or network), but collisions may happen, in
24+ // which case an "ambiguous result" error is produced. In case of a collision,
25+ // the caller should try with a longer prefix or the full-length ID.
1926func TruncateID (id string ) string {
2027 if i := strings .IndexRune (id , ':' ); i >= 0 {
2128 id = id [i + 1 :]
You can’t perform that action at this time.
0 commit comments