resource

package
v0.0.4-0...-95ce5f7 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ignore

func Ignore(is ErrorIs, err error) error

Ignore any errors that satisfy the supplied ErrorIs function by returning nil. Errors that do not satisfy the supplied function are returned unmodified.

func IgnoreAny

func IgnoreAny(err error, is ...ErrorIs) error

IgnoreAny ignores errors that satisfy any of the supplied ErrorIs functions by returning nil. Errors that do not satisfy any of the supplied functions are returned unmodified.

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound returns the supplied error, or nil if the error indicates a Kubernetes resource was not found.

func IsAPIError

func IsAPIError(err error) bool

IsAPIError returns true if the given error's type is of Kubernetes API error.

func IsAPIErrorWrapped

func IsAPIErrorWrapped(err error) bool

IsAPIErrorWrapped returns true if err is a K8s API error, or recursively wraps a K8s API error

Types

type APIFinalizer

type APIFinalizer struct {
	client.Client
	// contains filtered or unexported fields
}

An APIFinalizer adds and removes finalizers to and from a resource.

func NewAPIFinalizer

func NewAPIFinalizer(c client.Client, finalizer string) *APIFinalizer

NewAPIFinalizer returns a new APIFinalizer.

func (*APIFinalizer) AddFinalizer

func (a *APIFinalizer) AddFinalizer(ctx context.Context, obj Object) error

AddFinalizer to the supplied Managed resource.

func (*APIFinalizer) AddFinalizerString

func (a *APIFinalizer) AddFinalizerString(ctx context.Context, obj Object, finalizerString string) error

AddFinalizer to the supplied Managed resource.

func (*APIFinalizer) HasOtherFinalizer

func (a *APIFinalizer) HasOtherFinalizer(ctx context.Context, obj Object) (bool, error)

func (*APIFinalizer) RemoveFinalizer

func (a *APIFinalizer) RemoveFinalizer(ctx context.Context, obj Object) error

RemoveFinalizer from the supplied Managed resource.

func (*APIFinalizer) RemoveFinalizerString

func (a *APIFinalizer) RemoveFinalizerString(ctx context.Context, obj Object, finalizerString string) error

RemoveFinalizer from the supplied Managed resource.

type APIPatchingApplicator

type APIPatchingApplicator struct {
	client.Client
}

An APIPatchingApplicator applies changes to an object by either creating or patching it in a Kubernetes API server.

func NewAPIPatchingApplicator

func NewAPIPatchingApplicator(c client.Client) APIPatchingApplicator

NewAPIPatchingApplicator returns an Applicator that applies changes to an object by either creating or patching it in a Kubernetes API server.

func (*APIPatchingApplicator) Apply

Apply changes to the supplied object. The object will be created if it does not exist, or patched if it does. If the object does exist, it will only be patched if the passed object has the same or an empty resource version.

type Applicator

type Applicator interface {
	Apply(context.Context, client.Object, ...ApplyOption) error
}

An Applicator applies changes to an object.

type ApplyFn

type ApplyFn func(context.Context, client.Object, ...ApplyOption) error

An ApplyFn is a function that satisfies the Applicator interface.

func (ApplyFn) Apply

func (fn ApplyFn) Apply(ctx context.Context, o client.Object, ao ...ApplyOption) error

Apply changes to the supplied object.

type ApplyOption

type ApplyOption func(ctx context.Context, current, desired runtime.Object) error

An ApplyOption is called before patching the current object to match the desired object. ApplyOptions are not called if no current object exists.

func UpdateFn

func UpdateFn(fn func(current, desired runtime.Object)) ApplyOption

UpdateFn returns an ApplyOption that is used to modify the current object to match fields of the desired.

type ClientApplicator

type ClientApplicator struct {
	client.Client
	Applicator
}

A ClientApplicator may be used to build a single 'client' that satisfies both client.Client and Applicator.

type ErrorIs

type ErrorIs func(err error) bool

An ErrorIs function returns true if an error satisfies a particular condition.

type FinalizerFns

type FinalizerFns struct {
	AddFinalizerFn          func(ctx context.Context, obj Object) error
	RemoveFinalizerFn       func(ctx context.Context, obj Object) error
	HasOtherFinalizerFn     func(ctx context.Context, obj Object) (bool, error)
	AddFinalizerStringFn    func(ctx context.Context, obj Object, finalizerString string) error
	RemoveFinalizerStringFn func(ctx context.Context, obj Object, finalizerString string) error
}

A FinalizerFns satisfy the Finalizer interface.

func (FinalizerFns) AddFinalizer

func (f FinalizerFns) AddFinalizer(ctx context.Context, obj Object) error

AddFinalizer to the supplied resource.

func (FinalizerFns) AddFinalizerString

func (f FinalizerFns) AddFinalizerString(ctx context.Context, obj Object, finalizerString string) error

AddFinalizer to the supplied resource.

func (FinalizerFns) HasOtherFinalizer

func (f FinalizerFns) HasOtherFinalizer(ctx context.Context, obj Object) (bool, error)

RemoveFinalizer from the supplied resource.

func (FinalizerFns) RemoveFinalizer

func (f FinalizerFns) RemoveFinalizer(ctx context.Context, obj Object) error

RemoveFinalizer from the supplied resource.

func (FinalizerFns) RemoveFinalizerString

func (f FinalizerFns) RemoveFinalizerString(ctx context.Context, obj Object, finalizerString string) error

RemoveFinalizer from the supplied resource.

type Object

type Object interface {
	metav1.Object
	runtime.Object
}

An Object is a Kubernetes object.

Jump to

Keyboard shortcuts

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