Documentation ¶
Overview ¶
Package mutation allows a caller to automatically register, lookup and call API mutation functions. It is similar to runtime.Scheme and is designed to make writing and consuming API mutation functions easier. This registry also handles adding scheme defaults, even if no mutation functions are defined for that type. Any type where defaulting is desired should be registered. Functions are designed to update the incoming object, or new object, which will then have a patch generated and returned to the master Mutation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MutateFunc ¶
type MutateFunc func(req *admissionv1.AdmissionRequest, obj runtime.Object)
type MutateUpdateFunc ¶
type MutateUpdateFunc func(req *admissionv1.AdmissionRequest, old, new runtime.Object)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is used to store and lookup references to mutation functions for given Kubernetes API types. API types will be converted into internal API versions during mutation, then converted back to the target version when generating the patch.
func NewRegistry ¶
NewRegistry creates a new empty registry, backed by the provided Scheme.
func (*Registry) AddMutateFunc ¶
func (r *Registry) AddMutateFunc(obj runtime.Object, fn MutateFunc) error
AddMutateFunc will add a new mutation function to the register. The function will be run whenever a Mutate is called with a CREATE operation, and API type whose internal version is registered. Registered types MUST be that of the internal version of the target resource kind.
func (*Registry) AddMutateUpdateFunc ¶
func (r *Registry) AddMutateUpdateFunc(obj runtime.Object, fn MutateUpdateFunc) error
AddMutateFunc will add a new mutation function to the register. The function will be run whenever a Mutate is called with an UPDATE operation, and API type whose internal version is registered. Registered types MUST be that of the internal version of the target resource kind.
func (*Registry) Mutate ¶
func (r *Registry) Mutate(req *admissionv1.AdmissionRequest) ([]byte, error)
Mutate will run all mutation functions registed on CREATE and UPDATE operations over the internal type of the given resource. The object is converted to its internal version before either a CREATE or UPDATE mutation is applied to the object. The object is then converted to the requested version, and defaults applied for that schema. A JSON patch is then generated for the target resource version. Defaulting is always applied against the given resource, regardless of whether any mutation functions are defined.