generic

package
v1.4.5-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package generic provides a generic object store interface and a generic label/field matching type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeFieldsSets added in v1.2.0

func MergeFieldsSets(source fields.Set, fragment fields.Set) fields.Set

MergeFieldsSets merges a fields'set from fragment into the source.

func NewRawStorage added in v1.4.0

func NewRawStorage(config *storagebackend.Config) (storage.Interface, factory.DestroyFunc)

NewRawStorage creates the low level kv storage. This is a work-around for current two layer of same storage interface. TODO: Once cacher is enabled on all registries (event registry is special), we will remove this method.

func ObjectMetaFieldsSet added in v1.2.0

func ObjectMetaFieldsSet(objectMeta *api.ObjectMeta, hasNamespaceField bool) fields.Set

ObjectMetaFieldsSet returns a fields that represents the ObjectMeta.

func UndecoratedStorage added in v1.2.0

func UndecoratedStorage(
	config *storagebackend.Config,
	capacity int,
	objectType runtime.Object,
	resourcePrefix string,
	scopeStrategy rest.NamespaceScopedStrategy,
	newListFunc func() runtime.Object,
	trigger storage.TriggerPublisherFunc) (storage.Interface, factory.DestroyFunc)

Returns given 'storageInterface' without any decoration.

Types

type AttrFunc

type AttrFunc func(obj runtime.Object) (label labels.Set, field fields.Set, err error)

AttrFunc returns label and field sets for List or Watch to compare against, or an error.

type Matcher

type Matcher interface {
	// Matches should return true if obj matches this matcher's requirements.
	Matches(obj runtime.Object) (matchesThisObject bool, err error)

	// If this matcher matches a single object, return the key for that
	// object and true here. This will greatly increase efficiency. You
	// must still implement Matches(). Note that key does NOT need to
	// include the object's namespace.
	MatchesSingle() (key string, matchesSingleObject bool)

	// For any known index, if a matcher can match only (a subset) of objects
	// that return <value> for a given index, a pair (<index name>, <value>)
	// will be returned.
	MatcherIndex() []storage.MatchValue
}

Matcher can return true if an object matches the Matcher's selection criteria. If it is known that the matcher will match only a single object then MatchesSingle should return the key of that object and true. This is an optimization only--Matches() should continue to work.

type RESTOptions added in v1.2.0

type RESTOptions struct {
	StorageConfig           *storagebackend.Config
	Decorator               StorageDecorator
	DeleteCollectionWorkers int

	ResourcePrefix string
}

RESTOptions is set of configuration options to generic registries.

type SelectionPredicate

type SelectionPredicate struct {
	Label       labels.Selector
	Field       fields.Selector
	GetAttrs    AttrFunc
	IndexFields []string
}

SelectionPredicate implements a generic predicate that can be passed to GenericRegistry's List or Watch methods. Implements the Matcher interface.

func (*SelectionPredicate) MatcherIndex added in v1.4.0

func (s *SelectionPredicate) MatcherIndex() []storage.MatchValue

For any index defined by IndexFields, if a matcher can match only (a subset) of objects that return <value> for a given index, a pair (<index name>, <value>) wil be returned. TODO: Consider supporting also labels.

func (*SelectionPredicate) Matches

func (s *SelectionPredicate) Matches(obj runtime.Object) (bool, error)

Matches returns true if the given object's labels and fields (as returned by s.GetAttrs) match s.Label and s.Field. An error is returned if s.GetAttrs fails.

func (*SelectionPredicate) MatchesSingle added in v0.15.0

func (s *SelectionPredicate) MatchesSingle() (string, bool)

MatchesSingle will return (name, true) if and only if s.Field matches on the object's name.

type StorageDecorator added in v1.2.0

type StorageDecorator func(
	config *storagebackend.Config,
	capacity int,
	objectType runtime.Object,
	resourcePrefix string,
	scopeStrategy rest.NamespaceScopedStrategy,
	newListFunc func() runtime.Object,
	trigger storage.TriggerPublisherFunc) (storage.Interface, factory.DestroyFunc)

StorageDecorator is a function signature for producing a storage.Interface from given parameters.

Directories

Path Synopsis
Package etcd has a generic implementation of a registry that stores things in etcd.
Package etcd has a generic implementation of a registry that stores things in etcd.
Package rest has generic implementations of resources used for REST responses
Package rest has generic implementations of resources used for REST responses

Jump to

Keyboard shortcuts

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