rest

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package rest contains libraries for implementing resource request handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAttrs

func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error)

GetAttrs returns labels.Set, fields.Set, and error in case the given runtime.Object is not a ObjectMetaProvider

func SelectableFields

func SelectableFields(obj *metav1.ObjectMeta) fields.Set

SelectableFields returns a field set that represents the object.

Types

type DefaultStrategy

type DefaultStrategy struct {
	Object runtime.Object
	runtime.ObjectTyper
	TableConvertor rest.TableConvertor
}

DefaultStrategy implements Strategy. DefaultStrategy may be embedded in another struct to override is implementation. DefaultStrategy will delegate to functions specified on the resource type go structs if implemented. See the typeintf package for the implementable functions.

func (DefaultStrategy) AllowCreateOnUpdate

func (d DefaultStrategy) AllowCreateOnUpdate() bool

AllowCreateOnUpdate is used by the Store

func (DefaultStrategy) AllowUnconditionalUpdate

func (d DefaultStrategy) AllowUnconditionalUpdate() bool

AllowUnconditionalUpdate is used by the Store

func (DefaultStrategy) Canonicalize

func (DefaultStrategy) Canonicalize(obj runtime.Object)

Canonicalize calls the Canonicalize function on obj if supported, otherwise does nothing.

func (DefaultStrategy) ConvertToTable

func (d DefaultStrategy) ConvertToTable(
	ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)

ConvertToTable is used for printing the resource from kubectl get

func (DefaultStrategy) GenerateName

func (d DefaultStrategy) GenerateName(base string) string

GenerateName generates a new name for a resource without one.

func (DefaultStrategy) GetSingularName added in v0.9.0

func (d DefaultStrategy) GetSingularName() string

SingularNameProvider

func (DefaultStrategy) Match

Match is the filter used by the generic etcd backend to watch events from etcd to clients of the apiserver only interested in specific labels/fields.

func (DefaultStrategy) NamespaceScoped

func (d DefaultStrategy) NamespaceScoped() bool

NamespaceScoped is used to register the resource as namespaced or non-namespaced.

func (DefaultStrategy) PrepareForCreate

func (DefaultStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)

PrepareForCreate calls the PrepareForCreate function on obj if supported, otherwise does nothing.

func (DefaultStrategy) PrepareForUpdate

func (DefaultStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)

PrepareForUpdate calls the PrepareForUpdate function on obj if supported, otherwise does nothing.

func (DefaultStrategy) ShortNames added in v0.3.2

func (d DefaultStrategy) ShortNames() []string

ShortNames is used to register short names for easier scripting.

func (DefaultStrategy) Validate

Validate calls the Validate function on obj if supported, otherwise does nothing.

func (DefaultStrategy) ValidateUpdate

func (DefaultStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList

ValidateUpdate calls the ValidateUpdate function on obj if supported, otherwise does nothing.

func (DefaultStrategy) WarningsOnCreate added in v0.4.2

func (d DefaultStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string

func (DefaultStrategy) WarningsOnUpdate added in v0.4.2

func (d DefaultStrategy) WarningsOnUpdate(ctx context.Context, old, new runtime.Object) []string

type ResourceHandlerProvider

type ResourceHandlerProvider = apiserver.StorageProvider

ResourceHandlerProvider provides a request handler for a resource

func New

New returns a new etcd backed request handler for the resource.

func NewStatus

func NewStatus(obj resource.ObjectWithStatusSubResource) (
	parent resource.Object,
	path string,
	request resource.Object,
	handler ResourceHandlerProvider)

NewStatus returns a new etcd backed request handler for the resource "status" subresource.

func NewStatusWithFn

func NewStatusWithFn(obj resource.Object, fn StoreFn) ResourceHandlerProvider

NewStatusWithFn returns a new etcd backed request handler for the "status" subresource, applying the StoreFn to the Store.

func NewStatusWithStrategy

func NewStatusWithStrategy(obj resource.Object, s Strategy) ResourceHandlerProvider

NewStatusWithStrategy returns a new etcd backed request handler using the provided Strategy for the "status" subresource.

func NewWithFn

NewWithFn returns a new etcd backed request handler, applying the StoreFn to the Store.

func NewWithStrategy

func NewWithStrategy(obj resource.Object, s Strategy) ResourceHandlerProvider

NewWithStrategy returns a new etcd backed request handler using the provided Strategy.

type ResourceStorageFn

type ResourceStorageFn func() (request resource.Object, storage ResourceHandlerProvider)

ResourceStorageFn is a function that returns the objects required to register a resource into an apiserver. request is the resource type (e.g. &v1.Deployment{}), storage is the storage implementation that handles the requests. A ResourceFn can be used with builder.APIServer.WithResourceAndStorageProvider(fn())

type StaticHandlerProvider

type StaticHandlerProvider struct {
	rest.Storage
}

StaticHandlerProvider returns itself as the request handler.

func (StaticHandlerProvider) Get

Get returns itself as the handler

type StatusSubResourceStrategy

type StatusSubResourceStrategy struct {
	Strategy
}

StatusSubResourceStrategy defines a default Strategy for the status subresource.

func (StatusSubResourceStrategy) PrepareForUpdate

func (s StatusSubResourceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)

PrepareForUpdate calls the PrepareForUpdate function on obj if supported, otherwise does nothing.

type StoreFn

type StoreFn func(*genericregistry.Store, *generic.StoreOptions)

StoreFn defines a function which modifies the Store before it is initialized.

type Strategy

type Strategy interface {
	WarningsOnCreate(ctx context.Context, obj runtime.Object) []string
	AllowCreateOnUpdate() bool
	AllowUnconditionalUpdate() bool
	Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate
	rest.RESTUpdateStrategy
	rest.RESTCreateStrategy
	rest.RESTDeleteStrategy
	rest.TableConvertor
	rest.ShortNamesProvider
	rest.SingularNameProvider
}

Strategy defines functions that are invoked prior to storing a Kubernetes resource.

type SubResourceStorageFn

type SubResourceStorageFn func() (path string, parent resource.Object, request resource.Object, storage ResourceHandlerProvider)

SubResourceStorageFn is a function that returns objects required to register a subresource into an apiserver path is the subresource path from the parent (e.g. "scale"), parent is the resource the subresource is under (e.g. &v1.Deployment{}), request is the subresource request (e.g. &Scale{}), storage is the storage implementation that handles the requests. A SubResourceStorageFn can be used with builder.APIServer.WithSubResourceAndStorageProvider(fn())

Jump to

Keyboard shortcuts

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