docker: github.com/docker/docker/pkg/truncindex Index | Files

package truncindex

import "github.com/docker/docker/pkg/truncindex"

Package truncindex 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

Package Files

truncindex.go

Variables

var (
    // ErrEmptyPrefix is an error returned if the prefix was empty.
    ErrEmptyPrefix = errors.New("Prefix can't be empty")

    // ErrIllegalChar is returned when a space is in the ID
    ErrIllegalChar = errors.New("illegal character: ' '")

    // ErrNotExist is returned when ID or its prefix not found in index.
    ErrNotExist = errors.New("ID does not exist")
)

type ErrAmbiguousPrefix Uses

type ErrAmbiguousPrefix struct {
    // contains filtered or unexported fields
}

ErrAmbiguousPrefix is returned if the prefix was ambiguous (multiple ids for the prefix).

func (ErrAmbiguousPrefix) Error Uses

func (e ErrAmbiguousPrefix) Error() string

type TruncIndex Uses

type TruncIndex struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

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 Uses

func NewTruncIndex(ids []string) (idx *TruncIndex)

NewTruncIndex creates a new TruncIndex and initializes with a list of IDs.

func (*TruncIndex) Add Uses

func (idx *TruncIndex) Add(id string) error

Add adds a new ID to the TruncIndex.

func (*TruncIndex) Delete Uses

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 Uses

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 Uses

func (idx *TruncIndex) Iterate(handler func(id string))

Iterate iterates over all stored IDs and passes each of them to the given handler. Take care that the handler method does not call any public method on truncindex as the internal locking is not reentrant/recursive and will result in deadlock.

Package truncindex imports 5 packages (graph) and is imported by 1100 packages. Updated 2019-06-15. Refresh now. Tools for package owners.