rest

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 17 Imported by: 16

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) 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) 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 v1.0.3

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

WarningsOnCreate sends warning header on create

func (DefaultStrategy) WarningsOnUpdate added in v1.0.3

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

WarningsOnUpdate sends warning header on update

type ParentStaticHandlerProvider added in v1.0.3

type ParentStaticHandlerProvider struct {
	rest.Storage
	ParentProvider ResourceHandlerProvider
}

ParentStaticHandlerProvider returns itself as the request handler, but with the parent storage plumbed in the context.

func (ParentStaticHandlerProvider) Get added in v1.0.3

Get returns itself as the handler

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 NewSubResourceWithStrategy

func NewSubResourceWithStrategy(parent resource.Object, subResource resource.SubResource, s Strategy) ResourceHandlerProvider

NewSubResourceWithStrategy returns a new etcd backed request handler for subresource using the provided Strategy.

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 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 {
	AllowCreateOnUpdate() bool
	AllowUnconditionalUpdate() bool
	Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate
	rest.RESTUpdateStrategy
	rest.RESTCreateStrategy
	rest.RESTDeleteStrategy
	rest.TableConvertor
}

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