MCPcopy Index your code
hub / github.com/moby/moby / TruncateID

Function TruncateID

daemon/internal/stringid/stringid.go:26–34  ·  view source on GitHub ↗

TruncateID returns a shorthand version of a string identifier for presentation. For convenience, it accepts both digests ("sha256:xxxx") and IDs without an algorithm prefix. It truncates the algorithm (if any) before truncating the ID. The length of the truncated ID is currently fixed, but users sho

(id string)

Source from the content-addressed store, hash-verified

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.
26func TruncateID(id string) string {
27 if i := strings.IndexRune(id, ':'); i >= 0 {
28 id = id[i+1:]
29 }
30 if len(id) > shortLen {
31 id = id[:shortLen]
32 }
33 return id
34}
35
36// GenerateRandomID returns a unique, 64-character ID consisting of a-z, 0-9.
37// It guarantees that the ID, when truncated ([TruncateID]) does not consist

Callers 15

killProcessDirectlyFunction · 0.92
buildEndpointDNSNamesFunction · 0.92
IDMethod · 0.92
ImageIDMethod · 0.92
ImageDeleteMethod · 0.92
UpdateProgressMethod · 0.92
UpdateProgressMethod · 0.92
pullTagMethod · 0.92
epShortIdFunction · 0.92
sbJoinMethod · 0.92

Calls

no outgoing calls

Tested by 3

createNetworkDBInstancesFunction · 0.74
TestNetworkDBIslandsFunction · 0.74
TestTruncateIDFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…