generic

package
v0.0.0-...-6aabd98 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2014 License: Apache-2.0 Imports: 4 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 FilterList

func FilterList(list runtime.Object, m Matcher) (filtered runtime.Object, err error)

FilterList filters any list object that conforms to the api conventions, provided that 'm' works with the concrete type of list.

Types

type AttrFunc

type AttrFunc func(obj runtime.Object) (label, field labels.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(obj runtime.Object) (bool, error)
}

Matcher can return true if an object matches the Matcher's selection criteria.

func MatcherFunc

func MatcherFunc(f func(obj runtime.Object) (bool, error)) Matcher

MatcherFunc makes a matcher from the provided function. For easy definition of matchers for testing.

type Registry

type Registry interface {
	List(api.Context, Matcher) (runtime.Object, error)
	Create(ctx api.Context, id string, obj runtime.Object) error
	Update(ctx api.Context, id string, obj runtime.Object) error
	Get(ctx api.Context, id string) (runtime.Object, error)
	Delete(ctx api.Context, id string) error
	Watch(ctx api.Context, m Matcher, resourceVersion string) (watch.Interface, error)
}

Registry knows how to store & list any runtime.Object. Can be used for any object types which don't require special features from the storage layer.

type SelectionPredicate

type SelectionPredicate struct {
	Label    labels.Selector
	Field    labels.Selector
	GetAttrs AttrFunc
}

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

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.

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.

Jump to

Keyboard shortcuts

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