rest

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 7,459

Documentation

Overview

Package rest defines common logic around changes to Kubernetes-style resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeCreate

func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime.Object) error

BeforeCreate ensures that common operations for all resources are performed on creation. It only returns errors that can be converted to api.Status. It invokes PrepareForCreate, then Validate. It returns nil if the object should be created.

func BeforeDelete

func BeforeDelete(strategy RESTDeleteStrategy, ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) (graceful, gracefulPending bool, err error)

BeforeDelete tests whether the object can be gracefully deleted. If graceful is set, the object should be gracefully deleted. If gracefulPending is set, the object has already been gracefully deleted (and the provided grace period is longer than the time to deletion). An error is returned if the condition cannot be checked or the gracePeriodSeconds is invalid. The options argument may be updated with default values if graceful is true. Second place where we set deletionTimestamp is pkg/registry/generic/registry/store.go. This function is responsible for setting deletionTimestamp during gracefulDeletion, other one for cascading deletions.

func BeforeUpdate

func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old runtime.Object) error

BeforeUpdate ensures that common operations for all resources are performed on update. It only returns errors that can be converted to api.Status. It will invoke update validation with the provided existing and updated objects. It sets zero values only if the object does not have a zero value for the respective field.

func CheckGeneratedNameError

func CheckGeneratedNameError(ctx context.Context, strategy RESTCreateStrategy, err error, obj runtime.Object) error

CheckGeneratedNameError checks whether an error that occurred creating a resource is due to generation being unable to pick a valid name.

func EnsureObjectNamespaceMatchesRequestNamespace added in v0.24.0

func EnsureObjectNamespaceMatchesRequestNamespace(requestNamespace string, obj metav1.Object) error

EnsureObjectNamespaceMatchesRequestNamespace returns an error if obj.Namespace and requestNamespace are both populated and do not match. If either is unpopulated, it modifies obj as needed to ensure obj.GetNamespace() == requestNamespace.

func ExpectedNamespaceForResource added in v0.24.0

func ExpectedNamespaceForResource(requestNamespace string, resource schema.GroupVersionResource) string

ExpectedNamespaceForResource returns the expected namespace for a resource, given the request namespace.

func ExpectedNamespaceForScope added in v0.24.0

func ExpectedNamespaceForScope(requestNamespace string, namespaceScoped bool) string

ExpectedNamespaceForScope returns the expected namespace for a resource, given the request namespace and resource scope.

func FillObjectMetaSystemFields

func FillObjectMetaSystemFields(meta metav1.Object)

FillObjectMetaSystemFields populates fields that are managed by the system on ObjectMeta.

func ValidateAllObjectFunc

func ValidateAllObjectFunc(ctx context.Context, obj runtime.Object) error

ValidateAllObjectFunc is a "admit everything" instance of ValidateObjectFunc.

func ValidateAllObjectUpdateFunc

func ValidateAllObjectUpdateFunc(ctx context.Context, obj, old runtime.Object) error

ValidateAllObjectUpdateFunc is a "admit everything" instance of ValidateObjectUpdateFunc.

func WipeObjectMetaSystemFields added in v0.25.0

func WipeObjectMetaSystemFields(meta metav1.Object)

WipeObjectMetaSystemFields erases fields that are managed by the system on ObjectMeta.

Types

type CategoriesProvider

type CategoriesProvider interface {
	Categories() []string
}

CategoriesProvider allows a resource to specify which groups of resources (categories) it's part of. Categories can be used by API clients to refer to a batch of resources by using a single name (e.g. "all" could translate to "pod,rc,svc,...").

type CollectionDeleter

type CollectionDeleter interface {
	// DeleteCollection selects all resources in the storage matching given 'listOptions'
	// and deletes them. The delete attempt is validated by the deleteValidation first.
	// If 'options' are provided, the resource will attempt to honor them or return an
	// invalid request error.
	// DeleteCollection may not be atomic - i.e. it may delete some objects and still
	// return an error after it. On success, returns a list of deleted objects.
	DeleteCollection(ctx context.Context, deleteValidation ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)
}

CollectionDeleter is an object that can delete a collection of RESTful resources.

type Connecter

type Connecter interface {
	// Connect returns an http.Handler that will handle the request/response for a given API invocation.
	// The provided responder may be used for common API responses. The responder will write both status
	// code and body, so the ServeHTTP method should exit after invoking the responder. The Handler will
	// be used for a single API request and then discarded. The Responder is guaranteed to write to the
	// same http.ResponseWriter passed to ServeHTTP.
	Connect(ctx context.Context, id string, options runtime.Object, r Responder) (http.Handler, error)

	// NewConnectOptions returns an empty options object that will be used to pass
	// options to the Connect method. If nil, then a nil options object is passed to
	// Connect. It may return a bool and a string. If true, the value of the request
	// path below the object will be included as the named string in the serialization
	// of the runtime object.
	NewConnectOptions() (runtime.Object, bool, string)

	// ConnectMethods returns the list of HTTP methods handled by Connect
	ConnectMethods() []string
}

Connecter is a storage object that responds to a connection request.

type CreateUpdateResetFieldsStrategy added in v0.21.0

type CreateUpdateResetFieldsStrategy interface {
	RESTCreateUpdateStrategy
	ResetFieldsStrategy
}

CreateUpdateResetFieldsStrategy is a union of RESTCreateUpdateStrategy and ResetFieldsStrategy.

type Creater

type Creater interface {
	// New returns an empty object that can be used with Create after request data has been put into it.
	// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
	New() runtime.Object

	// Create creates a new version of a resource.
	Create(ctx context.Context, obj runtime.Object, createValidation ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)
}

Creater is an object that can create an instance of a RESTful object.

type CreaterUpdater

type CreaterUpdater interface {
	Creater
	Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)
}

CreaterUpdater is a storage object that must support both create and update. Go prevents embedded interfaces that implement the same method.

type GarbageCollectionDeleteStrategy

type GarbageCollectionDeleteStrategy interface {
	// DefaultGarbageCollectionPolicy returns the default garbage collection behavior.
	DefaultGarbageCollectionPolicy(ctx context.Context) GarbageCollectionPolicy
}

GarbageCollectionDeleteStrategy must be implemented by the registry that wants to orphan dependents by default.

type GarbageCollectionPolicy

type GarbageCollectionPolicy string
const (
	DeleteDependents GarbageCollectionPolicy = "DeleteDependents"
	OrphanDependents GarbageCollectionPolicy = "OrphanDependents"
	// Unsupported means that the resource knows that it cannot be GC'd, so the finalizers
	// should never be set in storage.
	Unsupported GarbageCollectionPolicy = "Unsupported"
)

type Getter

type Getter interface {
	// Get finds a resource in the storage by name and returns it.
	// Although it can return an arbitrary error value, IsNotFound(err) is true for the
	// returned error value err when the specified resource is not found.
	Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)
}

Getter is an object that can retrieve a named RESTful resource.

type GetterWithOptions

type GetterWithOptions interface {
	// Get finds a resource in the storage by name and returns it.
	// Although it can return an arbitrary error value, IsNotFound(err) is true for the
	// returned error value err when the specified resource is not found.
	// The options object passed to it is of the same type returned by the NewGetOptions
	// method.
	// TODO: Pass metav1.GetOptions.
	Get(ctx context.Context, name string, options runtime.Object) (runtime.Object, error)

	// NewGetOptions returns an empty options object that will be used to pass
	// options to the Get method. It may return a bool and a string, if true, the
	// value of the request path below the object will be included as the named
	// string in the serialization of the runtime object. E.g., returning "path"
	// will convert the trailing request scheme value to "path" in the map[string][]string
	// passed to the converter.
	NewGetOptions() (runtime.Object, bool, string)
}

GetterWithOptions is an object that retrieve a named RESTful resource and takes additional options on the get request. It allows a caller to also receive the subpath of the GET request.

type GracefulDeleter

type GracefulDeleter interface {
	// Delete finds a resource in the storage and deletes it.
	// The delete attempt is validated by the deleteValidation first.
	// If options are provided, the resource will attempt to honor them or return an invalid
	// request error.
	// Although it can return an arbitrary error value, IsNotFound(err) is true for the
	// returned error value err when the specified resource is not found.
	// Delete *may* return the object that was deleted, or a status object indicating additional
	// information about deletion.
	// It also returns a boolean which is set to true if the resource was instantly
	// deleted or false if it will be deleted asynchronously.
	Delete(ctx context.Context, name string, deleteValidation ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)
}

GracefulDeleter knows how to pass deletion options to allow delayed deletion of a RESTful object.

type GroupVersionAcceptor added in v0.22.0

type GroupVersionAcceptor interface {
	AcceptsGroupVersion(gv schema.GroupVersion) bool
}

GroupVersionAcceptor is used to determine if a particular GroupVersion is acceptable to send to an endpoint. This is used for endpoints which accept multiple versions (which is extremely rare). The only known instance is pods/evictions which accepts policy/v1, but also policy/v1beta1 for backwards compatibility.

type GroupVersionKindProvider

type GroupVersionKindProvider interface {
	GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind
}

GroupVersionKindProvider is used to specify a particular GroupVersionKind to discovery. This is used for polymorphic endpoints which generally point to foreign versions. Scale refers to Scale.v1beta1.extensions for instance. This trumps KindProvider since it is capable of providing the information required. TODO KindProvider (only used by federation) should be removed and replaced with this, but that presents greater risk late in 1.8.

type KindProvider

type KindProvider interface {
	Kind() string
}

KindProvider specifies a different kind for its API than for its internal storage. This is necessary for external objects that are not compiled into the api server. For such objects, there is no in-memory representation for the object, so they must be represented as generic objects (e.g. runtime.Unknown), but when we present the object as part of API discovery we want to present the specific kind, not the generic internal representation.

type Lister

type Lister interface {
	// NewList returns an empty object that can be used with the List call.
	// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
	NewList() runtime.Object
	// List selects resources in the storage which match to the selector. 'options' can be nil.
	List(ctx context.Context, options *metainternalversion.ListOptions) (runtime.Object, error)
	// TableConvertor ensures all list implementers also implement table conversion
	TableConvertor
}

Lister is an object that can retrieve resources that match the provided field and label criteria.

type MayReturnFullObjectDeleter added in v0.18.0

type MayReturnFullObjectDeleter interface {
	DeleteReturnsDeletedObject() bool
}

MayReturnFullObjectDeleter may return deleted object (instead of a simple status) on deletion.

type NamedCreater

type NamedCreater interface {
	// New returns an empty object that can be used with Create after request data has been put into it.
	// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
	New() runtime.Object

	// Create creates a new version of a resource. It expects a name parameter from the path.
	// This is needed for create operations on subresources which include the name of the parent
	// resource in the path.
	Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)
}

NamedCreater is an object that can create an instance of a RESTful object using a name parameter.

type NamespaceScopedStrategy

type NamespaceScopedStrategy interface {
	// NamespaceScoped returns if the object must be in a namespace.
	NamespaceScoped() bool
}

NamespaceScopedStrategy has a method to tell if the object must be in a namespace.

type Patcher

type Patcher interface {
	Getter
	Updater
}

Patcher is a storage object that supports both get and update.

type RESTCreateStrategy

type RESTCreateStrategy interface {
	runtime.ObjectTyper
	// The name generator is used when the standard GenerateName field is set.
	// The NameGenerator will be invoked prior to validation.
	names.NameGenerator

	// NamespaceScoped returns true if the object must be within a namespace.
	NamespaceScoped() bool
	// PrepareForCreate is invoked on create before validation to normalize
	// the object.  For example: remove fields that are not to be persisted,
	// sort order-insensitive list fields, etc.  This should not remove fields
	// whose presence would be considered a validation error.
	//
	// Often implemented as a type check and an initailization or clearing of
	// status. Clear the status because status changes are internal. External
	// callers of an api (users) should not be setting an initial status on
	// newly created objects.
	PrepareForCreate(ctx context.Context, obj runtime.Object)
	// Validate returns an ErrorList with validation errors or nil.  Validate
	// is invoked after default fields in the object have been filled in
	// before the object is persisted.  This method should not mutate the
	// object.
	Validate(ctx context.Context, obj runtime.Object) field.ErrorList
	// WarningsOnCreate returns warnings to the client performing a create.
	// WarningsOnCreate is invoked after default fields in the object have been filled in
	// and after Validate has passed, before Canonicalize is called, and the object is persisted.
	// This method must not mutate the object.
	//
	// Be brief; limit warnings to 120 characters if possible.
	// Don't include a "Warning:" prefix in the message (that is added by clients on output).
	// Warnings returned about a specific field should be formatted as "path.to.field: message".
	// For example: `spec.imagePullSecrets[0].name: invalid empty name ""`
	//
	// Use warning messages to describe problems the client making the API request should correct or be aware of.
	// For example:
	// - use of deprecated fields/labels/annotations that will stop working in a future release
	// - use of obsolete fields/labels/annotations that are non-functional
	// - malformed or invalid specifications that prevent successful handling of the submitted object,
	//   but are not rejected by validation for compatibility reasons
	//
	// Warnings should not be returned for fields which cannot be resolved by the caller.
	// For example, do not warn about spec fields in a subresource creation request.
	WarningsOnCreate(ctx context.Context, obj runtime.Object) []string
	// Canonicalize allows an object to be mutated into a canonical form. This
	// ensures that code that operates on these objects can rely on the common
	// form for things like comparison.  Canonicalize is invoked after
	// validation has succeeded but before the object has been persisted.
	// This method may mutate the object. Often implemented as a type check or
	// empty method.
	Canonicalize(obj runtime.Object)
}

RESTCreateStrategy defines the minimum validation, accepted input, and name generation behavior to create an object that follows Kubernetes API conventions.

type RESTCreateUpdateStrategy

type RESTCreateUpdateStrategy interface {
	RESTCreateStrategy
	// AllowCreateOnUpdate returns true if the object can be created by a PUT.
	AllowCreateOnUpdate() bool
	// PrepareForUpdate is invoked on update before validation to normalize
	// the object.  For example: remove fields that are not to be persisted,
	// sort order-insensitive list fields, etc.  This should not remove fields
	// whose presence would be considered a validation error.
	PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
	// ValidateUpdate is invoked after default fields in the object have been
	// filled in before the object is persisted.  This method should not mutate
	// the object.
	ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
	// WarningsOnUpdate returns warnings to the client performing the update.
	// WarningsOnUpdate is invoked after default fields in the object have been filled in
	// and after ValidateUpdate has passed, before Canonicalize is called, and before the object is persisted.
	// This method must not mutate either object.
	//
	// Be brief; limit warnings to 120 characters if possible.
	// Don't include a "Warning:" prefix in the message (that is added by clients on output).
	// Warnings returned about a specific field should be formatted as "path.to.field: message".
	// For example: `spec.imagePullSecrets[0].name: invalid empty name ""`
	//
	// Use warning messages to describe problems the client making the API request should correct or be aware of.
	// For example:
	// - use of deprecated fields/labels/annotations that will stop working in a future release
	// - use of obsolete fields/labels/annotations that are non-functional
	// - malformed or invalid specifications that prevent successful handling of the submitted object,
	//   but are not rejected by validation for compatibility reasons
	//
	// Warnings should not be returned for fields which cannot be resolved by the caller.
	// For example, do not warn about spec fields in a status update.
	WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string
	// AllowUnconditionalUpdate returns true if the object can be updated
	// unconditionally (irrespective of the latest resource version), when
	// there is no resource version specified in the object.
	AllowUnconditionalUpdate() bool
}

RESTCreateUpdateStrategy is a union of RESTUpdateStrategy and RESTCreateStrategy, and it defines the minimum validation, accepted input, and name generation behavior to create and update an object that follows Kubernetes API conventions.

type RESTDeleteStrategy

type RESTDeleteStrategy interface {
	runtime.ObjectTyper
}

RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes API conventions.

type RESTGracefulDeleteStrategy

type RESTGracefulDeleteStrategy interface {
	// CheckGracefulDelete should return true if the object can be gracefully deleted and set
	// any default values on the DeleteOptions.
	// NOTE: if return true, `options.GracePeriodSeconds` must be non-nil (nil will fail),
	// that's what tells the deletion how "graceful" to be.
	CheckGracefulDelete(ctx context.Context, obj runtime.Object, options *metav1.DeleteOptions) bool
}

RESTGracefulDeleteStrategy must be implemented by the registry that supports graceful deletion.

type RESTUpdateStrategy

type RESTUpdateStrategy interface {
	runtime.ObjectTyper
	// NamespaceScoped returns true if the object must be within a namespace.
	NamespaceScoped() bool
	// AllowCreateOnUpdate returns true if the object can be created by a PUT.
	AllowCreateOnUpdate() bool
	// PrepareForUpdate is invoked on update before validation to normalize
	// the object.  For example: remove fields that are not to be persisted,
	// sort order-insensitive list fields, etc.  This should not remove fields
	// whose presence would be considered a validation error.
	PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
	// ValidateUpdate is invoked after default fields in the object have been
	// filled in before the object is persisted.  This method should not mutate
	// the object.
	ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList
	// WarningsOnUpdate returns warnings to the client performing the update.
	// WarningsOnUpdate is invoked after default fields in the object have been filled in
	// and after ValidateUpdate has passed, before Canonicalize is called, and before the object is persisted.
	// This method must not mutate either object.
	//
	// Be brief; limit warnings to 120 characters if possible.
	// Don't include a "Warning:" prefix in the message (that is added by clients on output).
	// Warnings returned about a specific field should be formatted as "path.to.field: message".
	// For example: `spec.imagePullSecrets[0].name: invalid empty name ""`
	//
	// Use warning messages to describe problems the client making the API request should correct or be aware of.
	// For example:
	// - use of deprecated fields/labels/annotations that will stop working in a future release
	// - use of obsolete fields/labels/annotations that are non-functional
	// - malformed or invalid specifications that prevent successful handling of the submitted object,
	//   but are not rejected by validation for compatibility reasons
	//
	// Warnings should not be returned for fields which cannot be resolved by the caller.
	// For example, do not warn about spec fields in a status update.
	WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string
	// Canonicalize allows an object to be mutated into a canonical form. This
	// ensures that code that operates on these objects can rely on the common
	// form for things like comparison.  Canonicalize is invoked after
	// validation has succeeded but before the object has been persisted.
	// This method may mutate the object.
	Canonicalize(obj runtime.Object)
	// AllowUnconditionalUpdate returns true if the object can be updated
	// unconditionally (irrespective of the latest resource version), when
	// there is no resource version specified in the object.
	AllowUnconditionalUpdate() bool
}

RESTUpdateStrategy defines the minimum validation, accepted input, and name generation behavior to update an object that follows Kubernetes API conventions. A resource may have many UpdateStrategies, depending on the call pattern in use.

type Redirector

type Redirector interface {
	// ResourceLocation should return the remote location of the given resource, and an optional transport to use to request it, or an error.
	ResourceLocation(ctx context.Context, id string) (remoteLocation *url.URL, transport http.RoundTripper, err error)
}

Redirector know how to return a remote resource's location.

type ResetFieldsStrategy added in v0.21.0

type ResetFieldsStrategy interface {
	GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set
}

ResetFieldsStrategy is an optional interface that a storage object can implement if it wishes to provide the fields reset by its strategies.

type ResourceStreamer

type ResourceStreamer interface {
	// InputStream should return an io.ReadCloser if the provided object supports streaming. The desired
	// api version and an accept header (may be empty) are passed to the call. If no error occurs,
	// the caller may return a flag indicating whether the result should be flushed as writes occur
	// and a content type string that indicates the type of the stream.
	// If a null stream is returned, a StatusNoContent response wil be generated.
	InputStream(ctx context.Context, apiVersion, acceptHeader string) (stream io.ReadCloser, flush bool, mimeType string, err error)
}

ResourceStreamer is an interface implemented by objects that prefer to be streamed from the server instead of decoded directly.

type Responder

type Responder interface {
	// Object writes the provided object to the response. Invoking this method multiple times is undefined.
	Object(statusCode int, obj runtime.Object)
	// Error writes the provided error to the response. This method may only be invoked once.
	Error(err error)
}

Responder abstracts the normal response behavior for a REST method and is passed to callers that may wish to handle the response directly in some cases, but delegate to the normal error or object behavior in other cases.

type Scoper

type Scoper interface {
	// NamespaceScoped returns true if the storage is namespaced
	NamespaceScoped() bool
}

Scoper indicates what scope the resource is at. It must be specified. It is usually provided automatically based on your strategy.

type ShortNamesProvider

type ShortNamesProvider interface {
	ShortNames() []string
}

ShortNamesProvider is an interface for RESTful storage services. Delivers a list of short names for a resource. The list is used by kubectl to have short names representation of resources.

type SingularNameProvider added in v0.27.0

type SingularNameProvider interface {
	GetSingularName() string
}

SingularNameProvider returns singular name of resources. This is used by kubectl discovery to have singular name representation of resources. In case of shortcut conflicts(with CRD shortcuts) singular name should always map to this resource.

type StandardStorage

type StandardStorage interface {
	Getter
	Lister
	CreaterUpdater
	GracefulDeleter
	CollectionDeleter
	Watcher

	// Destroy cleans up its resources on shutdown.
	// Destroy has to be implemented in thread-safe way and be prepared
	// for being called more than once.
	Destroy()
}

StandardStorage is an interface covering the common verbs. Provided for testing whether a resource satisfies the normal storage methods. Use Storage when passing opaque storage objects.

type Storage

type Storage interface {
	// New returns an empty object that can be used with Create and Update after request data has been put into it.
	// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
	New() runtime.Object

	// Destroy cleans up its resources on shutdown.
	// Destroy has to be implemented in thread-safe way and be prepared
	// for being called more than once.
	Destroy()
}

Storage is a generic interface for RESTful storage services. Resources which are exported to the RESTful API of apiserver need to implement this interface. It is expected that objects may implement any of the below interfaces.

Consider using StorageWithReadiness whenever possible.

type StorageMetadata

type StorageMetadata interface {
	// ProducesMIMETypes returns a list of the MIME types the specified HTTP verb (GET, POST, DELETE,
	// PATCH) can respond with.
	ProducesMIMETypes(verb string) []string

	// ProducesObject returns an object the specified HTTP verb respond with. It will overwrite storage object if
	// it is not nil. Only the type of the return object matters, the value will be ignored.
	ProducesObject(verb string) interface{}
}

StorageMetadata is an optional interface that callers can implement to provide additional information about their Storage objects.

type StorageVersionProvider

type StorageVersionProvider interface {
	// StorageVersion returns a group versioner, which will outputs the gvk
	// an object will be converted to before persisted in etcd, given a
	// list of kinds the object might belong to.
	StorageVersion() runtime.GroupVersioner
}

StorageVersionProvider is an optional interface that a storage object can implement if it wishes to disclose its storage version.

type StorageWithReadiness added in v0.31.0

type StorageWithReadiness interface {
	Storage

	// ReadinessCheck allows for checking storage readiness.
	ReadinessCheck() error
}

StorageWithReadiness extends Storage interface with the readiness check.

type SubresourceObjectMetaPreserver added in v0.25.9

type SubresourceObjectMetaPreserver interface {
	// PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate indicates that a
	// handler should preserve fields of ObjectMeta that are managed by the system.
	PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate() bool
}

SubresourceObjectMetaPreserver adds configuration options to a Creater for subresources.

type TableConvertor

type TableConvertor interface {
	ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error)
}

func NewDefaultTableConvertor

func NewDefaultTableConvertor(defaultQualifiedResource schema.GroupResource) TableConvertor

NewDefaultTableConvertor creates a default convertor; the provided resource is used for error messages if no resource info can be determined from the context passed to ConvertToTable.

type TransformFunc

type TransformFunc func(ctx context.Context, newObj runtime.Object, oldObj runtime.Object) (transformedNewObj runtime.Object, err error)

TransformFunc is a function to transform and return newObj

type UpdateResetFieldsStrategy added in v0.21.0

type UpdateResetFieldsStrategy interface {
	RESTUpdateStrategy
	ResetFieldsStrategy
}

UpdateResetFieldsStrategy is a union of RESTUpdateStrategy and ResetFieldsStrategy.

type UpdatedObjectInfo

type UpdatedObjectInfo interface {
	// Returns preconditions built from the updated object, if applicable.
	// May return nil, or a preconditions object containing nil fields,
	// if no preconditions can be determined from the updated object.
	Preconditions() *metav1.Preconditions

	// UpdatedObject returns the updated object, given a context and old object.
	// The only time an empty oldObj should be passed in is if a "create on update" is occurring (there is no oldObj).
	UpdatedObject(ctx context.Context, oldObj runtime.Object) (newObj runtime.Object, err error)
}

UpdatedObjectInfo provides information about an updated object to an Updater. It requires access to the old object in order to return the newly updated object.

func DefaultUpdatedObjectInfo

func DefaultUpdatedObjectInfo(obj runtime.Object, transformers ...TransformFunc) UpdatedObjectInfo

DefaultUpdatedObjectInfo returns an UpdatedObjectInfo impl based on the specified object.

func WrapUpdatedObjectInfo

func WrapUpdatedObjectInfo(objInfo UpdatedObjectInfo, transformers ...TransformFunc) UpdatedObjectInfo

WrapUpdatedObjectInfo returns an UpdatedObjectInfo impl that delegates to the specified objInfo, then calls the passed transformers

type Updater

type Updater interface {
	// New returns an empty object that can be used with Update after request data has been put into it.
	// This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object)
	New() runtime.Object

	// Update finds a resource in the storage and updates it. Some implementations
	// may allow updates creates the object - they should set the created boolean
	// to true.
	Update(ctx context.Context, name string, objInfo UpdatedObjectInfo, createValidation ValidateObjectFunc, updateValidation ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)
}

Updater is an object that can update an instance of a RESTful object.

type ValidateObjectFunc

type ValidateObjectFunc func(ctx context.Context, obj runtime.Object) error

ValidateObjectFunc is a function to act on a given object. An error may be returned if the hook cannot be completed. A ValidateObjectFunc may NOT transform the provided object.

func AdmissionToValidateObjectDeleteFunc

func AdmissionToValidateObjectDeleteFunc(admit admission.Interface, staticAttributes admission.Attributes, objInterfaces admission.ObjectInterfaces) ValidateObjectFunc

AdmissionToValidateObjectDeleteFunc returns a admission validate func for object deletion

func AdmissionToValidateObjectFunc

func AdmissionToValidateObjectFunc(admit admission.Interface, staticAttributes admission.Attributes, o admission.ObjectInterfaces) ValidateObjectFunc

AdmissionToValidateObjectFunc converts validating admission to a rest validate object func

type ValidateObjectUpdateFunc

type ValidateObjectUpdateFunc func(ctx context.Context, obj, old runtime.Object) error

ValidateObjectUpdateFunc is a function to act on a given object and its predecessor. An error may be returned if the hook cannot be completed. An UpdateObjectFunc may NOT transform the provided object.

func AdmissionToValidateObjectUpdateFunc

func AdmissionToValidateObjectUpdateFunc(admit admission.Interface, staticAttributes admission.Attributes, o admission.ObjectInterfaces) ValidateObjectUpdateFunc

AdmissionToValidateObjectUpdateFunc converts validating admission to a rest validate object update func

type Watcher

type Watcher interface {
	// 'label' selects on labels; 'field' selects on the object's fields. Not all fields
	// are supported; an error should be returned if 'field' tries to select on a field that
	// isn't supported. 'resourceVersion' allows for continuing/starting a watch at a
	// particular version.
	Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
}

Watcher should be implemented by all Storage objects that want to offer the ability to watch for changes through the watch api.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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