etcd

package
v0.12.1-0...-6d465c4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package etcd has a generic implementation of a registry that stores things in etcd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NamespaceKeyFunc

func NamespaceKeyFunc(ctx api.Context, prefix string, name string) (string, error)

NamespaceKeyFunc is the default function for constructing etcd paths to a resource relative to prefix enforcing namespace rules. If no namespace is on context, it errors.

func NamespaceKeyRootFunc

func NamespaceKeyRootFunc(ctx api.Context, prefix string) string

NamespaceKeyRootFunc is the default function for constructing etcd paths to resource directories enforcing namespace rules.

Types

type Etcd

type Etcd struct {
	// Called to make a new object, should return e.g., &api.Pod{}
	NewFunc func() runtime.Object

	// Called to make a new listing object, should return e.g., &api.PodList{}
	NewListFunc func() runtime.Object

	// Used for error reporting
	EndpointName string

	// Used for listing/watching; should not include trailing "/"
	KeyRootFunc func(ctx api.Context) string

	// Called for Create/Update/Get/Delete
	KeyFunc func(ctx api.Context, name string) (string, error)

	// Called to get the name of an object
	ObjectNameFunc func(obj runtime.Object) (string, error)

	// Return the TTL objects should be persisted with. Update is true if this
	// is an operation against an existing object.
	TTLFunc func(obj runtime.Object, update bool) (uint64, error)

	// Returns a matcher corresponding to the provided labels and fields.
	PredicateFunc func(label labels.Selector, field fields.Selector) generic.Matcher

	// Called on all objects returned from the underlying store, after
	// the exit hooks are invoked. Decorators are intended for integrations
	// that are above etcd and should only be used for specific cases where
	// storage of the value in etcd is not appropriate, since they cannot
	// be watched.
	Decorator rest.ObjectFunc
	// Allows extended behavior during creation
	CreateStrategy rest.RESTCreateStrategy
	// On create of an object, attempt to run a further operation.
	AfterCreate rest.ObjectFunc
	// Allows extended behavior during updates
	UpdateStrategy rest.RESTUpdateStrategy
	// On update of an object, attempt to run a further operation.
	AfterUpdate rest.ObjectFunc
	// If true, return the object that was deleted. Otherwise, return a generic
	// success status response.
	ReturnDeletedObject bool
	// On deletion of an object, attempt to run a further operation.
	AfterDelete rest.ObjectFunc

	// Used for all etcd access functions
	Helper tools.EtcdHelper
}

Etcd implements generic.Registry, backing it with etcd storage. It's intended to be embeddable, so that you can implement any non-generic functions if needed. You must supply a value for every field below before use; these are left public as it's meant to be overridable if need be. This object is intended to be copyable so that it can be used in different ways but share the same underlying behavior.

The intended use of this type is embedding within a Kind specific RESTStorage implementation. This type provides CRUD semantics on a Kubelike resource, handling details like conflict detection with ResourceVersion and semantics. The RESTCreateStrategy and RESTUpdateStrategy are generic across all backends, and encapsulate logic specific to the API.

TODO: make the default exposed methods exactly match a generic RESTStorage

func (*Etcd) Create

func (e *Etcd) Create(ctx api.Context, obj runtime.Object) (runtime.Object, error)

Create inserts a new item according to the unique key from the object.

func (*Etcd) CreateWithName

func (e *Etcd) CreateWithName(ctx api.Context, name string, obj runtime.Object) error

CreateWithName inserts a new item with the provided name DEPRECATED: use Create instead

func (*Etcd) Delete

func (e *Etcd) Delete(ctx api.Context, name string) (runtime.Object, error)

Delete removes the item from etcd.

func (*Etcd) Get

func (e *Etcd) Get(ctx api.Context, name string) (runtime.Object, error)

Get retrieves the item from etcd.

func (*Etcd) List

func (e *Etcd) List(ctx api.Context, label labels.Selector, field fields.Selector) (runtime.Object, error)

List returns a list of items matching labels and field

func (*Etcd) ListPredicate

func (e *Etcd) ListPredicate(ctx api.Context, m generic.Matcher) (runtime.Object, error)

ListPredicate returns a list of all the items matching m.

func (*Etcd) New

func (e *Etcd) New() runtime.Object

New implements RESTStorage

func (*Etcd) NewList

func (e *Etcd) NewList() runtime.Object

NewList implements RESTLister

func (*Etcd) Update

func (e *Etcd) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error)

Update performs an atomic update and set of the object. Returns the result of the update or an error. If the registry allows create-on-update, the create flow will be executed.

func (*Etcd) UpdateWithName

func (e *Etcd) UpdateWithName(ctx api.Context, name string, obj runtime.Object) error

UpdateWithName updates the item with the provided name DEPRECATED: use Update instead

func (*Etcd) Watch

func (e *Etcd) Watch(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

WatchPredicate starts a watch for the items that m matches. TODO: Detect if m references a single object instead of a list.

func (*Etcd) WatchPredicate

func (e *Etcd) WatchPredicate(ctx api.Context, m generic.Matcher, resourceVersion string) (watch.Interface, error)

WatchPredicate starts a watch for the items that m matches. TODO: Detect if m references a single object instead of a list.

Jump to

Keyboard shortcuts

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