Documentation
¶
Overview ¶
Package rest defines common logic around changes to Kubernetes resources.
Index ¶
- Variables
- func BeforeCreate(strategy RESTCreateStrategy, ctx api.Context, obj runtime.Object) error
- func BeforeDelete(strategy RESTDeleteStrategy, ctx api.Context, obj runtime.Object, ...) (graceful, gracefulPending bool, err error)
- func BeforeUpdate(strategy RESTUpdateStrategy, ctx api.Context, obj, old runtime.Object) error
- func CheckGeneratedNameError(strategy RESTCreateStrategy, err error, obj runtime.Object) error
- type ObjectFunc
- type RESTCreateStrategy
- type RESTDeleteStrategy
- type RESTUpdateStrategy
Constants ¶
This section is empty.
Variables ¶
var Services = svcStrategy{api.Scheme, api.SimpleNameGenerator}
Services is the default logic that applies when creating and updating Service objects.
Functions ¶
func BeforeCreate ¶
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 ResetBeforeCreate, then GenerateName, then Validate. It returns nil if the object should be created.
func BeforeDelete ¶
func BeforeDelete(strategy RESTDeleteStrategy, ctx api.Context, obj runtime.Object, options *api.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), and 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.
func BeforeUpdate ¶
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.
func CheckGeneratedNameError ¶
func CheckGeneratedNameError(strategy RESTCreateStrategy, err error, obj runtime.Object) error
CheckGeneratedNameError checks whether an error that occured creating a resource is due to generation being unable to pick a valid name.
Types ¶
type ObjectFunc ¶
ObjectFunc is a function to act on a given object. An error may be returned if the hook cannot be completed. An ObjectFunc may transform the provided object.
func AllFuncs ¶
func AllFuncs(fns ...ObjectFunc) ObjectFunc
AllFuncs returns an ObjectFunc that attempts to run all of the provided functions in order, returning early if there are any errors.
type RESTCreateStrategy ¶
type RESTCreateStrategy interface { runtime.ObjectTyper // The name generate is used when the standard GenerateName field is set. // The NameGenerator will be invoked prior to validation. api.NameGenerator // NamespaceScoped returns true if the object must be within a namespace. NamespaceScoped() bool // ResetBeforeCreate is invoked on create before validation to remove any fields // that may not be persisted. ResetBeforeCreate(obj runtime.Object) // Validate is invoked after default fields in the object have been filled in before // the object is persisted. Validate(obj runtime.Object) errors.ValidationErrorList }
RESTCreateStrategy defines the minimum validation, accepted input, and name generation behavior to create an object that follows Kubernetes API conventions.
var Nodes RESTCreateStrategy = nodeStrategy{api.Scheme, api.SimpleNameGenerator}
Nodes is the default logic that applies when creating and updating Node objects.
type RESTDeleteStrategy ¶
type RESTDeleteStrategy interface { runtime.ObjectTyper // CheckGracefulDelete should return true if the object can be gracefully deleted and set // any default values on the DeleteOptions. CheckGracefulDelete(obj runtime.Object, options *api.DeleteOptions) bool }
RESTDeleteStrategy defines deletion behavior on an object that follows Kubernetes API conventions.
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 // ValidateUpdate is invoked after default fields in the object have been filled in before // the object is persisted. ValidateUpdate(obj, old runtime.Object) errors.ValidationErrorList }
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.