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 (d DefaultStrategy) ShortNames() []string
- 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, old, new runtime.Object) []string
- type ResourceHandlerProvider
- func New(obj resource.Object) ResourceHandlerProvider
- func NewStatus(obj resource.ObjectWithStatusSubResource) (parent resource.Object, path string, request resource.Object, ...)
- func NewStatusWithFn(obj resource.Object, fn StoreFn) ResourceHandlerProvider
- func NewStatusWithStrategy(obj resource.Object, s Strategy) ResourceHandlerProvider
- func NewWithFn(obj resource.Object, fn StoreFn) ResourceHandlerProvider
- func NewWithStrategy(obj resource.Object, s Strategy) ResourceHandlerProvider
- type ResourceStorageFn
- type StaticHandlerProvider
- type StatusSubResourceStrategy
- 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) 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 ¶
ValidateUpdate calls the ValidateUpdate function on obj if supported, otherwise does nothing.
func (DefaultStrategy) WarningsOnCreate ¶ added in v0.4.2
func (DefaultStrategy) WarningsOnUpdate ¶ added in v0.4.2
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 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 ¶
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 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 }
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())