client

package
v1.93.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Clean is an alias for `DefaultCleaner().Clean`.
	Clean = DefaultCleaner().Clean

	// CleanAndEnsureGone is an alias for `DefaultCleanOps().CleanAndEnsureGone`.
	CleanAndEnsureGone = DefaultCleanOps().CleanAndEnsureGone
)

Functions

func ApplyToObjectKinds added in v1.81.0

func ApplyToObjectKinds(ctx context.Context, fn func(kind string, objectList client.ObjectList) flow.TaskFn, kindToObjectList map[string]client.ObjectList) error

ApplyToObjectKinds applies the passed function to all the object lists for the passed kinds.

func ApplyToObjects added in v1.81.0

func ApplyToObjects(ctx context.Context, objectList client.ObjectList, fn func(ctx context.Context, object client.Object) error) error

ApplyToObjects applies the passed function to all the objects in the list.

func AreObjectsRemaining

func AreObjectsRemaining(err error) bool

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 ForceDeleteObjects added in v1.81.0

func ForceDeleteObjects(c client.Client, namespace string, objectList client.ObjectList, opts ...client.ListOption) flow.TaskFn

ForceDeleteObjects lists and finalizes all the objects in the passed namespace and deletes them.

func NewObjectsRemaining

func NewObjectsRemaining(obj runtime.Object) error

NewObjectsRemaining returns a new error with the remaining objects.

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 DefaultCleanOps

func DefaultCleanOps() CleanOps

DefaultCleanOps are the default CleanOps.

func NewCleanOps

func NewCleanOps(ensurer GoneEnsurer, cleaner ...Cleaner) 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.

func (*CleanOptions) ApplyToClean added in v1.26.0

func (o *CleanOptions) ApplyToClean(co *CleanOptions)

ApplyToClean implements CleanOption for 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 DefaultCleaner

func DefaultCleaner() Cleaner

DefaultCleaner is the default Cleaner.

func DefaultVolumeSnapshotContentCleaner added in v1.39.0

func DefaultVolumeSnapshotContentCleaner() Cleaner

DefaultVolumeSnapshotContentCleaner is the default cleaner for VolumeSnapshotContents. The VolumeSnapshotCleaner initiates the deletion of VolumeSnapshots **after** they got deleted and the given deletion grace period is passed.

func NewCleaner

func NewCleaner(time timeutils.Ops, finalizer Finalizer) Cleaner

NewCleaner instantiates a new Cleaner with the given timeutils.Ops and finalizer.

func NewVolumeSnapshotContentCleaner added in v1.39.0

func NewVolumeSnapshotContentCleaner(time timeutils.Ops) Cleaner

NewVolumeSnapshotContentCleaner instantiates a new Cleaner with ability to clean VolumeSnapshotContents **after** they got deleted and the given deletion grace period is passed.

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 client.Object) error

	// HasFinalizers checks whether the given resource has finalizers.
	HasFinalizers(obj client.Object) (bool, error)
}

Finalizer checks and removes the finalizers of given resource.

func NewFinalizer

func NewFinalizer() Finalizer

NewFinalizer instantiates a default finalizer.

func NewNamespaceFinalizer

func NewNamespaceFinalizer() 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.

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 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 TolerateErrorFunc

type TolerateErrorFunc func(err error) bool

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.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL