Documentation ¶
Index ¶
- Variables
- func AreObjectsRemaining(err error) bool
- func EnsureGone(ctx context.Context, c client.Client, obj runtime.Object, ...) error
- func NewObjectsRemaining(remaining runtime.Object) error
- func RemainingObjects(err error) []runtime.Object
- type CleanOps
- type CleanOption
- type CleanOptions
- type Cleaner
- type DeleteWith
- type FinalizeGracePeriodSeconds
- type Finalizer
- type GoneEnsurer
- type GoneEnsurerFunc
- type Limit
- type ListWith
- type MatchingFieldsSelector
- type MatchingLabelsSelector
- type TolerateErrorFunc
- type TolerateErrors
Constants ¶
This section is empty.
Variables ¶
var ( // Clean is an alias for `DefaultCleaner().Clean`. Clean = DefaultCleaner().Clean // CleanAndEnsureGone is an alias for `DefaultCleanOps().CleanAndEnsureGone`. CleanAndEnsureGone = DefaultCleanOps().CleanAndEnsureGone )
Functions ¶
func AreObjectsRemaining ¶
AreObjectsRemaining checks whether the given error is an 'objects remaining error'.
func EnsureGone ¶
func EnsureGone(ctx context.Context, c client.Client, obj runtime.Object, opts ...client.ListOption) error
EnsureGone ensures that the given object or list is gone.
func NewObjectsRemaining ¶
NewObjectsRemaining returns a new error with the remaining objects.
func RemainingObjects ¶
RemainingObjects retrieves the remaining objects of an `AreObjectsRemaining` error.
If the error does not match `AreObjectsRemaining`, this returns nil.
Types ¶
type CleanOps ¶
type CleanOps interface { // CleanAndEnsureGone cleans the resource(s) and ensures that it/they are gone afterwards. CleanAndEnsureGone(ctx context.Context, c client.Client, obj runtime.Object, opts ...CleanOption) error }
CleanOps are ops to clean.
func NewCleanOps ¶
func NewCleanOps(cleaner Cleaner, ensurer GoneEnsurer) CleanOps
NewCleanOps instantiates new CleanOps with the given Cleaner and GoneEnsurer.
type CleanOption ¶
type CleanOption interface {
ApplyToClean(*CleanOptions)
}
CleanOption is a configuration that modifies options for a clean operation.
type CleanOptions ¶
type CleanOptions struct { ListOptions []client.ListOption DeleteOptions []client.DeleteOption FinalizeGracePeriodSeconds *int64 ErrorToleration []TolerateErrorFunc }
CleanOptions are options to clean certain resources. If FinalizeGracePeriodSeconds is set, the finalizers of the resources are removed if the resources still exist after their targeted termination date plus the FinalizeGracePeriodSeconds amount.
func (*CleanOptions) ApplyOptions ¶
func (o *CleanOptions) ApplyOptions(opts []CleanOption) *CleanOptions
ApplyOptions applies the OptFuncs to the CleanOptions.
type Cleaner ¶
type Cleaner interface { // Clean cleans the given resource(s). It first tries to delete them. If they are 'hanging' // in deletion state and `FinalizeGracePeriodSeconds` is specified, then they are finalized // once the `deletionTimestamp` is beyond that amount in the past. Clean(ctx context.Context, c client.Client, obj runtime.Object, opts ...CleanOption) error }
Cleaner is capable of deleting and finalizing resources.
func NewCRDCleaner ¶
func NewCRDCleaner() Cleaner
NewCRDCleaner instantiates a new Cleaner with ability to clean CustomResourceDefinitions.
func NewCleaner ¶
NewCleaner instantiates a new Cleaner with the given utiltime.Ops and finalizer.
func NewNamespaceCleaner ¶
func NewNamespaceCleaner(namespaceInterface typedcorev1.NamespaceInterface) Cleaner
NewNamespaceCleaner instantiates a new Cleaner with ability to clean namespaces.
type DeleteWith ¶
type DeleteWith []client.DeleteOption
DeleteWith uses the given delete options for a clean operation.
func (DeleteWith) ApplyToClean ¶
func (d DeleteWith) ApplyToClean(opts *CleanOptions)
ApplyToClean specifies deletion options for a clean operation.
type FinalizeGracePeriodSeconds ¶
type FinalizeGracePeriodSeconds int64
FinalizeGracePeriodSeconds specifies that a resource shall be finalized if it's been deleting without being gone beyond the deletion timestamp for the given seconds.
func (FinalizeGracePeriodSeconds) ApplyToClean ¶
func (s FinalizeGracePeriodSeconds) ApplyToClean(opts *CleanOptions)
ApplyToClean specifies a finalize grace period for a clean operation.
type Finalizer ¶
type Finalizer interface { // Finalize removes the resource finalizers (so it can be garbage collected). Finalize(ctx context.Context, c client.Client, obj runtime.Object) error // HasFinalizers checks whether the given resource has finalizers. HasFinalizers(obj runtime.Object) (bool, error) }
Finalizer checks and removes the finalizers of given resource.
func NewCRDFinalizer ¶
func NewCRDFinalizer() Finalizer
NewCRDFinalizer instantiates a CustomResourceDefinition finalizer.
func NewNamespaceFinalizer ¶
func NewNamespaceFinalizer(namespaceInterface typedcorev1.NamespaceInterface) Finalizer
NewNamespaceFinalizer instantiates a namespace finalizer.
type GoneEnsurer ¶
type GoneEnsurer interface { // EnsureGone ensures that the given resource is gone. If the resource is not gone, it will throw // a NewObjectsRemaining error. EnsureGone(ctx context.Context, c client.Client, obj runtime.Object, opts ...client.ListOption) error }
GoneEnsurer ensures that resource(s) are gone.
func DefaultGoneEnsurer ¶
func DefaultGoneEnsurer() GoneEnsurer
DefaultGoneEnsurer is the default GoneEnsurer.
func GoneBeforeEnsurer ¶
func GoneBeforeEnsurer(before time.Time) GoneEnsurer
GoneBeforeEnsurer returns an implementation of `GoneEnsurer` which is time aware.
type GoneEnsurerFunc ¶
type GoneEnsurerFunc func(ctx context.Context, c client.Client, obj runtime.Object, opts ...client.ListOption) error
GoneEnsurerFunc is a function that implements GoneEnsurer.
func (GoneEnsurerFunc) EnsureGone ¶
func (f GoneEnsurerFunc) EnsureGone(ctx context.Context, c client.Client, obj runtime.Object, opts ...client.ListOption) error
EnsureGone implements GoneEnsurer.
type Limit ¶
type Limit int64
Limit sets the given Limit on client.ListOptions.
TODO: Replace this with client.Limit (available from v0.3.0) https://github.com/kubernetes-sigs/controller-runtime/pull/341
func (Limit) ApplyToList ¶
func (l Limit) ApplyToList(opts *client.ListOptions)
ApplyToList restricts the list operation to gven limit.
type ListWith ¶
type ListWith []client.ListOption
ListWith uses the given list options for a clean operation.
func (ListWith) ApplyToClean ¶
func (d ListWith) ApplyToClean(opts *CleanOptions)
ApplyToClean specifies list options for a clean operation.
type MatchingFieldsSelector ¶
MatchingFieldsSelector filters the list/delete operation on the given field selector (or index in the case of cached lists). A struct is used because fields.Selector is an interface, which cannot be aliased.
TODO: Replace this with client.MatchingFieldsSelector (available from v0.2.1) https://github.com/kubernetes-sigs/controller-runtime/pull/578
func (MatchingFieldsSelector) ApplyToList ¶
func (m MatchingFieldsSelector) ApplyToList(opts *client.ListOptions)
ApplyToList restricts the list operation to match the field selector.
type MatchingLabelsSelector ¶
MatchingLabelsSelector filters the list/delete operation on the given label selector (or index in the case of cached lists). A struct is used because labels.Selector is an interface, which cannot be aliased.
TODO: Replace this with client.MatchingLabelsSelector (available from v0.2.1) https://github.com/kubernetes-sigs/controller-runtime/pull/578
func (MatchingLabelsSelector) ApplyToList ¶
func (m MatchingLabelsSelector) ApplyToList(opts *client.ListOptions)
ApplyToList restricts the list operation to match the label selector.
type TolerateErrorFunc ¶
TolerateErrorFunc is a function for tolerating errors.
type TolerateErrors ¶
type TolerateErrors []TolerateErrorFunc
TolerateErrors uses the given toleration funcs for a clean operation.
func (TolerateErrors) ApplyToClean ¶
func (m TolerateErrors) ApplyToClean(opts *CleanOptions)
ApplyToClean specifies a errors to be tolerated for a clean operation.