package truncindex

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

Index

Variables

var (
	// ErrNoID is thrown when attempting to use empty prefixes
	ErrNoID = errors.New("prefix can't be empty")
	// ErrDuplicateID is thrown when a duplicated id was found
	ErrDuplicateID = errors.New("multiple IDs were found")
)

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.

Source Files

truncindex.go

Version
v1.5.0-rc2
Published
Jan 28, 2015
Platform
js/wasm
Imports
5 packages
Last checked
1 minute ago

Tools for package owners.