Documentation ¶
Overview ¶
Package rest contains libraries for implementing resource request handlers.
Index ¶
- func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error)
- func SelectableFields(obj *metav1.ObjectMeta) fields.Set
- type DefaultStrategy
- func (d DefaultStrategy) AllowCreateOnUpdate() bool
- func (d DefaultStrategy) AllowUnconditionalUpdate() bool
- func (DefaultStrategy) Canonicalize(obj runtime.Object)
- func (d DefaultStrategy) ConvertToTable(ctx context.Context, obj runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)
- func (d DefaultStrategy) GenerateName(base string) string
- func (DefaultStrategy) Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate
- func (d DefaultStrategy) NamespaceScoped() bool
- func (DefaultStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)
- func (DefaultStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
- func (DefaultStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList
- func (DefaultStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
- func (d DefaultStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string
- func (d DefaultStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string
- type ParentStaticHandlerProvider
- type ResourceHandlerProvider
- func New(obj resource.Object) ResourceHandlerProvider
- func NewSubResourceWithStrategy(parent resource.Object, subResource resource.SubResource, s Strategy) ResourceHandlerProvider
- func NewWithFn(obj resource.Object, fn StoreFn) ResourceHandlerProvider
- func NewWithStrategy(obj resource.Object, s Strategy) ResourceHandlerProvider
- type ResourceStorageFn
- type StaticHandlerProvider
- type StoreFn
- type Strategy
- type SubResourceStorageFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAttrs ¶
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 ¶
func (DefaultStrategy) Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate
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 ¶
ValidateUpdate calls the ValidateUpdate function on obj if supported, otherwise does nothing.
func (DefaultStrategy) WarningsOnCreate ¶ added in v1.0.3
WarningsOnCreate sends warning header on create
func (DefaultStrategy) WarningsOnUpdate ¶ added in v1.0.3
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
func (p ParentStaticHandlerProvider) Get(s *runtime.Scheme, g generic.RESTOptionsGetter) (rest.Storage, error)
Get returns itself as the handler
type ResourceHandlerProvider ¶
type ResourceHandlerProvider = apiserver.StorageProvider
ResourceHandlerProvider provides a request handler for a resource
func New ¶
func New(obj resource.Object) ResourceHandlerProvider
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 ¶
func NewWithFn(obj resource.Object, fn StoreFn) ResourceHandlerProvider
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 ¶
StaticHandlerProvider returns itself as the request handler.
func (StaticHandlerProvider) Get ¶
func (p StaticHandlerProvider) Get(s *runtime.Scheme, g generic.RESTOptionsGetter) (rest.Storage, error)
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())