io

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIApplicator

type APIApplicator struct {
	// contains filtered or unexported fields
}

An APIPatchingApplicator applies changes to an object by either creating or patching it in a Kubernetes API server. For a detailed discussion of the reasoning behind these semantics, see this doc, https://pages.github.snooguts.net/reddit/achilles-docs/dev/sdk/sdk-apply-objects/.

func NewAPIPatchingApplicator

func NewAPIPatchingApplicator(c client.Client) *APIApplicator

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

func (*APIApplicator) Apply

func (a *APIApplicator) Apply(ctx context.Context, current client.Object, opts ...ApplyOption) error

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.

func (*APIApplicator) ApplyStatus

func (a *APIApplicator) ApplyStatus(ctx context.Context, o client.Object, opts ...ApplyOption) error

ApplyStatus updates the object's status subresource. If the object does not exist, an error will be returned.

type Applicator

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

An Applicator applies changes to an object.

type ApplyOption

type ApplyOption func(ctx context.Context, o client.Object, requestOpts *RequestOptions) error

An ApplyOption mutates the desired object before applying

func AsUpdate

func AsUpdate() ApplyOption

AsUpdate uses an update request to overwrite the entire object if it exists, rather than selective patching. Using this option without the optimistic lock implies a full overwrite of the object, so use with caution.

func WithControllerRef

func WithControllerRef(owner client.Object, scheme *runtime.Scheme) ApplyOption

WithControllerRef sets an owner reference on the object and controller flag to true. When used in the context of OutputSet, this option is used by default unless WithoutOwnerRef is specified.

func WithOptimisticLock

func WithOptimisticLock() ApplyOption

WithOptimisticLock returns an error if the desired object is missing the resource version

func WithOwnerRef

func WithOwnerRef(owner client.Object, scheme *runtime.Scheme) ApplyOption

WithOwnerRef sets an owner reference on the object and controller flag to false. Multiple owner references can be set on an object if their controller flag is false.

func WithRedditLabels

func WithRedditLabels(controllerName string) ApplyOption

WithRedditLabels applies a standard set of labels for managed resources.

func WithoutOwnerRefs

func WithoutOwnerRefs() ApplyOption

WithoutOwnerRefs explicitly prevents owner refs (either controller or owner) from being set on the applied object. Generally this should not be used—only set it if your controller is intentionally managing owner references on managed resources.

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 RequestOptions

type RequestOptions struct {
	// Update, if true, overrides the entire object with an update request (instead of selective patch)
	Update bool

	// EnforceOptimisticLock, if true, enforces usage of the optimistic resource lock by erroring
	// if the object to be updated doesn't include `meta.resourceVersion`
	EnforceOptimisticLock bool

	// WithoutOwnerRefs, if true, prevents any owner refs from being set on the applied object.
	// Generally this should not be used—only set it if your controller is intentionally managing owner references on
	// managed resources.
	WithoutOwnerRefs bool
	// contains filtered or unexported fields
}

options for the kube-apiserver request

type ResourceVersionMissing

type ResourceVersionMissing struct {
}

ResourceVersionMissing is returned if an object is missing a resource version

func (ResourceVersionMissing) Error

func (r ResourceVersionMissing) Error() string

Jump to

Keyboard shortcuts

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