File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,23 @@ var (
1616 // ErrEmptyPrefix is an error returned if the prefix was empty.
1717 ErrEmptyPrefix = errors .New ("Prefix can't be empty" )
1818
19- // ErrAmbiguousPrefix is returned if the prefix was ambiguous
20- // (multiple ids for the prefix).
21- ErrAmbiguousPrefix = errors .New ("Multiple IDs found with provided prefix" )
22-
2319 // ErrIllegalChar is returned when a space is in the ID
2420 ErrIllegalChar = errors .New ("illegal character: ' '" )
2521
2622 // ErrNotExist is returned when ID or its prefix not found in index.
2723 ErrNotExist = errors .New ("ID does not exist" )
2824)
2925
26+ // ErrAmbiguousPrefix is returned if the prefix was ambiguous
27+ // (multiple ids for the prefix).
28+ type ErrAmbiguousPrefix struct {
29+ prefix string
30+ }
31+
32+ func (e ErrAmbiguousPrefix ) Error () string {
33+ return fmt .Sprintf ("Multiple IDs found with provided prefix: %s" , e .prefix )
34+ }
35+
3036// TruncIndex allows the retrieval of string identifiers by any of their unique prefixes.
3137// This is used to retrieve image and container IDs by more convenient shorthand prefixes.
3238type TruncIndex struct {
@@ -105,7 +111,7 @@ func (idx *TruncIndex) Get(s string) (string, error) {
105111 if id != "" {
106112 // we haven't found the ID if there are two or more IDs
107113 id = ""
108- return ErrAmbiguousPrefix
114+ return ErrAmbiguousPrefix { prefix : string ( prefix )}
109115 }
110116 id = string (prefix )
111117 return nil
You can’t perform that action at this time.
0 commit comments