Documentation ¶
Overview ¶
Package truncindex package provides a general 'index tree', used by Docker in order to be able to reference containers by only a few unambiguous characters of their id.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyPrefix is an error returned if the prefix was empty. ErrEmptyPrefix = errors.New("Prefix can't be empty") // ErrAmbiguousPrefix is returned if the prefix was ambiguous // (multiple ids for the prefix). ErrAmbiguousPrefix = errors.New("Multiple IDs found with provided prefix") // ErrIllegalChar is returned when a space is in the ID ErrIllegalChar = errors.New("illegal character: ' '") )
Functions ¶
This section is empty.
Types ¶
type TruncIndex ¶
TruncIndex allows the retrieval of string identifiers by any of their unique prefixes. This is used to retrieve image and container IDs by more convenient shorthand prefixes.
func NewTruncIndex ¶
func NewTruncIndex(ids []string) (idx *TruncIndex)
NewTruncIndex creates a new TruncIndex and initializes with a list of IDs.
func (*TruncIndex) Add ¶
func (idx *TruncIndex) Add(id string) error
Add adds a new ID to the TruncIndex.
func (*TruncIndex) Delete ¶
func (idx *TruncIndex) Delete(id string) error
Delete removes an ID from the TruncIndex. If there are multiple IDs with the given prefix, an error is thrown.
func (*TruncIndex) Get ¶
func (idx *TruncIndex) Get(s string) (string, error)
Get retrieves an ID from the TruncIndex. If there are multiple IDs with the given prefix, an error is thrown.
func (*TruncIndex) Iterate ¶
func (idx *TruncIndex) Iterate(handler func(id string))
Iterate iterates over all stored IDs, and passes each of them to the given handler.