Documentation ¶
Overview ¶
Package operation implements lower-level functions to be used by any Kubernetes Object.
Index ¶
- func Create(c Conf) (reconcile.Result, error)
- func CreateOrUpdate(c Conf) (r reconcile.Result, err error)
- func Delete(c Conf) (reconcile.Result, error)
- func Update(c Conf) (reconcile.Result, error)
- type AfterCreateFunc
- type AfterDeleteFunc
- type AfterUpdateFunc
- type Conf
- type HookFunc
- type MaybeUpdateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create is a generic create function for any Kubernetes Object. This function can create the Object defined in Conf. This function is a lower level function and is supposed to be used by other Kubernetes Objects. However, this can also be used to create Custom Objects (or unsupported objects).
func CreateOrUpdate ¶
CreateOrUpdate is the combination of Create and Update. It can be used to create any Kubernetes Object. It catches the "IsAlreadyExists" error and tries to update the object.
func Delete ¶
Delete is a generic delete function for any Kubernetes Object. This function can be used to delete any Kubernetes Object defined in Conf. This is a lower-level function which is supposed to be used by other Kubernetes Objects. This can also be used to delete any Custom Objects (or unsupported Objects).
func Update ¶
Update is a generic update function for any Kubernetes Object. This can be used to update the objects using MaybeUpdateFunc defined in Conf. This is a lower-level function which is supposed to be used by other Objects. This can also be used to implement custom update logic on any Kubernetes Object. It fetches the Object with same metadata as the specified object from the cluster and update them using MaybeUpdateFunc.
Types ¶
type AfterCreateFunc ¶
type AfterCreateFunc HookFunc
AfterCreateFunc is the hook called after creating the object.
type AfterDeleteFunc ¶
type AfterDeleteFunc HookFunc
AfterDeleteFunc is the hook called after deleting the object.
type AfterUpdateFunc ¶
type AfterUpdateFunc HookFunc
AfterUpdateFunc is the hook called after updating the object.
type Conf ¶
type Conf struct { // Instance is the pointer to the owner object which is performing // operation on the Object. Instance interfaces.Object // Reconcile is the pointer to reconcile struct of the owner // Object. Reconcile interfaces.Reconcile // Object is the pointer to the object on which operation is to be // performed. Object interfaces.Object // ExistingObject is the pointer to the empty struct of Object // which is used to fetch the existing object from cluster // TODO: Figure out a way to avoid this ExistingObject interfaces.Object // OwnerReference is the flag used to by Create operation to // determine if owner reference needs to be set on the created // object. OwnerReference bool // MaybeUpdateFunc is used by Update operation to determine if // Update is required and also update the object MaybeUpdateFunc // AfterCreateFunc hook is called after creating the Object AfterCreateFunc // AfterUpdateFunc hook is called after updating the Object AfterUpdateFunc // AfterDeleteFunc hook is called after deleting the Object AfterDeleteFunc }
Conf is the struct used by all Operation functions. This can be used to pass various parameters which can be used by the functions.
type HookFunc ¶
type HookFunc func(interfaces.Object, interfaces.Reconcile) (reconcile.Result, error)
HookFunc is the function type which is used by various hooks. The function of this type can be used to hook custom logic in pre-defined operations.
type MaybeUpdateFunc ¶
type MaybeUpdateFunc func(interfaces.Object, interfaces.Object) (bool, error)
MaybeUpdateFunc is the update function type which is used for updating objects. The function gives the user flexibility to define there own update functions and pass them. The function is supposed to update the first argument and return true if update is required or else false. The function can return error if one occurs during comparison.