Documentation ¶
Index ¶
- func Annotate(ctx context.Context, target LabelAnnotatableFrom, key, value string)
- func Finalize(ctx context.Context, cl client.Client, name string, obj FinalizablePersister, ...) (bool, error)
- func Label(ctx context.Context, target LabelAnnotatableFrom, key, value string)
- func LabelManagedBy(ctx context.Context, target LabelAnnotatableFrom, value string)
- type CacheBypasserClient
- type DeleteOption
- type DeleteOptions
- type DeleteWithPropagationPolicy
- type Deleter
- type Finalizable
- type FinalizablePersister
- type IgnoreNilLabelAnnotatableFrom
- type IgnoreNilLoader
- type IgnoreNilOwnable
- type IgnoreNilOwnablePersister
- type IgnoreNilPersister
- type LabelAnnotatableFrom
- type Loader
- type LoaderFunc
- type Loaders
- type Ownable
- type OwnablePersister
- type OwnablePersisters
- type Owner
- type OwnerPersister
- type OwnershipPersister
- type Persister
- type RequiredError
- type RequiredLoader
- type RetryLoader
- type TypedObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Annotate ¶ added in v0.3.0
func Annotate(ctx context.Context, target LabelAnnotatableFrom, key, value string)
Annotate uses any LabelAnnotatableFrom object to assign the given annotation.
func Finalize ¶
func Finalize(ctx context.Context, cl client.Client, name string, obj FinalizablePersister, run func() error) (bool, error)
Finalize provides a lifecycle for finalization for an entity that implements FinalizablePersister.
If the entity is not in a finalizing state, a finalizer is added with the given name. The entity is automatically persisted.
If the entity is in a finalizing state, the given callback function is run. If it succeeds, the finalizer is removed and the entity is persisted.
This function returns true if the finalization callback successfully ran and the entity was updated. It returns false otherwise.
func Label ¶ added in v0.2.0
func Label(ctx context.Context, target LabelAnnotatableFrom, key, value string)
Label uses any LabelAnnotatableFrom object to assign the given label.
func LabelManagedBy ¶ added in v0.2.0
func LabelManagedBy(ctx context.Context, target LabelAnnotatableFrom, value string)
LabelManagedBy sets the "app.kubernetes.io/managed-by" label to a particular value.
Types ¶
type CacheBypasserClient ¶ added in v0.5.0
func CacheBypasserClientForManager ¶ added in v0.5.0
func CacheBypasserClientForManager(mgr manager.Manager) CacheBypasserClient
type DeleteOption ¶
type DeleteOption interface { // ApplyToDeleteOptions copies the configuration of this option to the given // deletion options. ApplyToDeleteOptions(target *DeleteOptions) }
DeleteOption is a setter for one or more deletion options.
type DeleteOptions ¶
type DeleteOptions struct {
PropagationPolicy client.PropagationPolicy
}
DeleteOptions are the options that a deletable entity is required to support.
func (*DeleteOptions) ApplyOptions ¶
func (o *DeleteOptions) ApplyOptions(opts []DeleteOption)
ApplyOptions runs each of the given options against this deletion options struct.
type DeleteWithPropagationPolicy ¶
type DeleteWithPropagationPolicy client.PropagationPolicy
DeleteWithPropagationPolicy causes the deletion to use the specified propagation policy semantically.
If this option is not used, propagation policy will be determined by the entity being deleted.
func (DeleteWithPropagationPolicy) ApplyToDeleteOptions ¶
func (dwpp DeleteWithPropagationPolicy) ApplyToDeleteOptions(target *DeleteOptions)
ApplyToDeleteOptions copies the configuration of this option to the given deletion options.
type Deleter ¶
type Deleter interface { // Delete removes this entity from the cluster. Delete(ctx context.Context, cl client.Client, opts ...DeleteOption) (bool, error) }
Deleter is the type of an entity that can be deleted from a cluster.
type Finalizable ¶
type Finalizable interface { // Finalizing returns true if this entity is currently in a finalizing // state. // // Usually, this is indicated by the presence of a deletion timestamp in // Kubernetes object metadata. Finalizing() bool // AddFinalizer sets the given finalizer in object metadata. It returns true // if the finalizer was added, and false if it already exists. AddFinalizer(ctx context.Context, name string) bool // RemoveFinalizer removes the given finalizer from object metadata. It // returns true if the finalizer was removed, and false if the finalizer did // not exist. RemoveFinalizer(ctx context.Context, name string) bool }
Finalizable is the type of an entity that supports finalizing.
type FinalizablePersister ¶
type FinalizablePersister interface { Finalizable Persister }
FinalizablePersister is a combined interface for a finalizable entity that can be saved to the cluster.
type IgnoreNilLabelAnnotatableFrom ¶
type IgnoreNilLabelAnnotatableFrom struct {
LabelAnnotatableFrom
}
IgnoreNilLabelAnnotatableFrom is an adapter for a label and annotation copier that makes sure its delegate has a value before copying.
func (IgnoreNilLabelAnnotatableFrom) LabelAnnotateFrom ¶
func (inlaf IgnoreNilLabelAnnotatableFrom) LabelAnnotateFrom(ctx context.Context, from metav1.Object)
LabelAnnotateFrom copies the labels from the given object metadata to this entity.
type IgnoreNilLoader ¶
type IgnoreNilLoader struct {
Loader
}
IgnoreNilLoader is an adapter for a loader that makes sure the loader has a value before attempting to load from it.
This loader is useful for loading optional dependencies.
type IgnoreNilOwnable ¶
type IgnoreNilOwnable struct {
Ownable
}
IgnoreNilOwnable is an adapter for an ownable entity that makes sure the entity has a value.
func (IgnoreNilOwnable) Owned ¶
func (ino IgnoreNilOwnable) Owned(ctx context.Context, owner TypedObject) error
Owned sets the ownerReferences controller for this entity to the given object, or does nothing if the underlying entity is nil or an interface with a nil value.
type IgnoreNilOwnablePersister ¶ added in v0.2.0
type IgnoreNilOwnablePersister struct {
OwnablePersister
}
IgnoreNilOwnablePersister combines IgnoreNilOwnable and IgnoreNilPersister.
func (IgnoreNilOwnablePersister) Owned ¶ added in v0.2.0
func (inop IgnoreNilOwnablePersister) Owned(ctx context.Context, owner TypedObject) error
Owned sets the ownerReferences controller for this entity to the given object, or does nothing if the underlying entity is nil or an interface with a nil value.
type IgnoreNilPersister ¶
type IgnoreNilPersister struct {
Persister
}
IgnoreNilPersister is an adapter for a persistable entity that makes sure the entity has a value.
type LabelAnnotatableFrom ¶
type LabelAnnotatableFrom interface { // LabelAnnotateFrom copies the labels from the given object metadata to // this entity. LabelAnnotateFrom(ctx context.Context, from metav1.Object) }
LabelAnnotatableFrom is the type of an entity that can copy labels and annotations from the given metadata.
type Loader ¶
type Loader interface { // Load finds this entity in the cluster and populates any necessary fields. // If there was an error locating the entity, this function returns false. Load(ctx context.Context, cl client.Client) (bool, error) }
Loader is the type of an entity that can be retrieved from a cluster.
func NewPredicateLoader ¶ added in v0.3.0
NewPredicateLoader creates a new loader that delegates to a given loader if a condition, evaluated upon Load being called, returns true.
type LoaderFunc ¶
LoaderFunc allows a function to be used as a loader.
type Loaders ¶
type Loaders []Loader
Loaders allows multiple loaders to be loaded at once, as if they were a single entity.
type Ownable ¶
type Ownable interface { // Owned sets the ownerReferences controller for this entity to the given // object. Owned(ctx context.Context, owner TypedObject) error }
Ownable is the type of an entity that can be a dependent of another object using the Kubernetes ownerReferences mechanism.
type OwnablePersister ¶
OwnablePersister is a combined interface for an object that can be owned and can be saved to the cluster.
type OwnablePersisters ¶
type OwnablePersisters []OwnablePersister
OwnablePersisters allows a collection of ownable persisters to be used as a single entity.
func (OwnablePersisters) Owned ¶
func (ops OwnablePersisters) Owned(ctx context.Context, owner TypedObject) error
Owned sets the ownerReferences controller for each entity in this collection to the given object.
type Owner ¶
type Owner interface { // Own sets the owner of the specified dependent entity to this entity. Own(ctx context.Context, other Ownable) error }
Owner is the type of an entity that can own other objects using the Kubernetes ownerReferences mechanism.
type OwnerPersister ¶
OwnerPersister is a combined interface for an object that can own other objects and can be saved to the cluster.
type OwnershipPersister ¶
type OwnershipPersister struct { Owner OwnerPersister Dependent OwnablePersister }
OwnershipPersister provides a lifecycle for managing the ownership of an entity or set of entities.
It first persists the owner so that its unique object ID is known. Then it sets the ownerReferences for the intended dependent. Finally, it persists all the dependents.
type Persister ¶
type Persister interface { // Persist saves this entity using the given client. Persist(ctx context.Context, cl client.Client) error }
Persister is the type of an entity that can be saved to a cluster.
type RequiredError ¶
type RequiredError struct { // Loader is the underlying loader that could not find the object. Loader Loader }
RequiredError is an error reported by RequiredLoader if the target cannot be found.
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
Error conforms a pointer to RequiredError to the error interface.
type RequiredLoader ¶
type RequiredLoader struct {
Loader
}
RequiredLoader is an adapter for a loader that ensures the entity exists.
type RetryLoader ¶
type RetryLoader interface { Loader // WithWaitOptions sets the options, like a backoff, to use, for waiting on // the condition. WithWaitOptions(opts ...retry.WaitOption) Loader }
RetryLoader is an adapter that continually retries loading until a condition is met.
func NewRetryLoader ¶
NewRetryLoader creates a new loader that delegates to the given loader. When the Load method is called, its result is mapped using the given condition function. This loader only successfully returns when the mapper function returns true (even in the case of errors).
type TypedObject ¶
type TypedObject struct { GVK schema.GroupVersionKind Object client.Object }
TypedObject is a Kubernetes runtime object with its resource group-version-kind attached from its schema.