truncindex

package
v0.338.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2016 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPrefix     = errors.New("Prefix can't be empty")
	ErrAmbiguousPrefix = errors.New("Multiple IDs found with provided prefix")
)

Functions

This section is empty.

Types

type TruncIndex

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

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 added in v0.327.0

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

Iterates over all stored IDs, and passes each of them to the given handler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL