registry

package
v0.0.0-...-1692a82 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 28 Imported by: 11

Documentation

Index

Constants

View Source
const (
	OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
)

Variables

This section is empty.

Functions

func NamespaceKeyFunc

func NamespaceKeyFunc(ctx context.Context, name string) (types.NamespacedName, error)

NamespaceKeyFunc is the default function for constructing storage paths to a resource relative to the given prefix enforcing namespace rules. If the context does not contain a namespace, it errors.

func NoNamespaceKeyFunc

func NoNamespaceKeyFunc(ctx context.Context, name string) (types.NamespacedName, error)

NoNamespaceKeyFunc is the default function for constructing storage paths to a resource relative to the given prefix without a namespace.

Types

type Store

type Store struct {
	Tracer trace.Tracer
	// NewFunc returns a new instance of the type this registry returns for a
	// GET of a single object, e.g.:
	//
	// curl GET /apis/group/version/namespaces/my-ns/myresource/name-of-object
	NewFunc func() runtime.Object

	// NewListFunc returns a new list of the type this registry; it is the
	// type returned when the resource is listed, e.g.:
	//
	// curl GET /apis/group/version/namespaces/my-ns/myresource
	NewListFunc func() runtime.Object

	// DefaultQualifiedResource is the pluralized name of the resource.
	// This field is used if there is no request info present in the context.
	// See qualifiedResourceFromContext for details.
	DefaultQualifiedResource schema.GroupResource

	// SingularQualifiedResource is the singular name of the resource.
	SingularQualifiedResource schema.GroupResource

	// KeyFunc returns the key for a specific object in the collection.
	// KeyFunc is called for Create/Update/Get/Delete. Note that 'namespace'
	// can be gotten from ctx.
	KeyFunc func(ctx context.Context, name string) (types.NamespacedName, error)

	// ObjectNameFunc returns the name of an object or an error.
	ObjectNameFunc func(obj runtime.Object) (string, error)

	// PredicateFunc returns a matcher corresponding to the provided labels
	// and fields. The SelectionPredicate returned should return true if the
	// object matches the given field and label selectors.
	PredicateFunc func(label labels.Selector, field fields.Selector) storage.SelectionPredicate

	// EnableGarbageCollection affects the handling of Update and Delete
	// requests. Enabling garbage collection allows finalizers to do work to
	// finalize this object before the store deletes it.
	//
	// If any store has garbage collection enabled, it must also be enabled in
	// the kube-controller-manager.
	EnableGarbageCollection bool

	// DeleteCollectionWorkers is the maximum number of workers in a single
	// DeleteCollection call. Delete requests for the items in a collection
	// are issued in parallel.
	DeleteCollectionWorkers int

	// GetStrategy implements resource-specific behavior during get.
	GetStrategy reststore.RESTGetStrategy

	// ListStrategy implements resource-specific behavior during list.
	ListStrategy reststore.RESTListStrategy

	// CreateStrategy implements resource-specific behavior during creation.
	CreateStrategy reststore.RESTCreateStrategy

	// UpdateStrategy implements resource-specific behavior during updates.
	UpdateStrategy reststore.RESTUpdateStrategy

	// DeleteStrategy implements resource-specific behavior during deletion.
	DeleteStrategy reststore.RESTDeleteStrategy

	WatchStrategy reststore.RESTWatchStrategy

	// ReturnDeletedObject determines whether the Store returns the object
	// that was deleted. Otherwise, return a generic success status response.
	ReturnDeletedObject bool

	// TableConvertor is an optional interface for transforming items or lists
	// of items into tabular output. If unset, the default will be used.
	TableConvertor rest.TableConvertor

	// DestroyFunc cleans up clients used by the underlying Storage; optional.
	// If set, DestroyFunc has to be implemented in thread-safe way and
	// be prepared for being called more than once.
	DestroyFunc func()
}

func (*Store) CompleteWithOptions

func (r *Store) CompleteWithOptions(options *generic.StoreOptions) error

CompleteWithOptions updates the store with the provided options and defaults common fields.

func (*Store) ConvertToTable

func (r *Store) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)

func (*Store) Create

func (r *Store) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

func (*Store) Delete

func (r *Store) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

Delete removes the item from storage. options can be mutated by rest.BeforeDelete due to a graceful deletion strategy.

func (*Store) DeleteCollection

func (r *Store) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection removes all items returned by List with a given ListOptions from storage.

DeleteCollection is currently NOT atomic. It can happen that only subset of objects will be deleted from storage, and then an error will be returned. In case of success, the list of deleted objects will be returned.

func (*Store) Destroy

func (r *Store) Destroy()

Destroy cleans up its resources on shutdown.

func (*Store) Get

func (r *Store) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

func (*Store) GetSingularName

func (r *Store) GetSingularName() string

func (*Store) List

List returns a list of items matching labels and field according to the store's PredicateFunc.

func (*Store) NamespaceScoped

func (r *Store) NamespaceScoped() bool

NamespaceScoped indicates whether the resource is namespaced

func (*Store) New

func (r *Store) New() runtime.Object

New implements RESTStorage.New.

func (*Store) NewList

func (r *Store) NewList() runtime.Object

NewList implements rest.Lister.

func (*Store) Update

func (r *Store) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (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. A bool is returned along with the object and any errors, to indicate object creation.

func (*Store) Watch

type TableConvertor

type TableConvertor struct {
	Resource schema.GroupResource
	// cells creates a single row of cells of the table from a runtime.Object
	Cells func(obj runtime.Object) []interface{}
	// columns stores column definitions for the table convertor
	Columns []metav1.TableColumnDefinition
}

func (TableConvertor) ConvertToTable

func (r TableConvertor) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)

ConvertToTable implements rest.TableConvertor

Jump to

Keyboard shortcuts

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