resources

package
v1.16.5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resources contains a set of Kubernetes generic utilities that are used by the operator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIfNotFound

func CreateIfNotFound[T client.Object](ctx context.Context, c client.Client, obj T) error

CreateIfNotFound creates the given object if it doesn't already exist

Types

type PatchType

type PatchType string

PatchType is the patch type to be used for patch requests

const (
	// PatchTypeStrategicMerge means use the strategic merge patch type, passing
	// just the diff to the API server
	PatchTypeStrategicMerge PatchType = "StrategicMerge"

	// PatchTypeMerge means use the merge strategy
	PatchTypeMerge PatchType = "Merge"
)

func (PatchType) BuildPatch

func (p PatchType) BuildPatch(current client.Object) client.Patch

BuildPatch creates a client.patch for the passed object

type Request

type Request[T client.Object] struct {
	// contains filtered or unexported fields
}

Request is a client request that adheres to the client.Client interface

func NewRequest

func NewRequest[T client.Object](c client.Client) *Request[T]

NewRequest instantiate a new request with the passed client

func (*Request[T]) CreateIfNotFound

func (r *Request[T]) CreateIfNotFound() *Request[T]

CreateIfNotFound will attempt to create the resource if it receives IsNotFound error

func (*Request[T]) Execute

func (r *Request[T]) Execute(
	ctx context.Context,
	proposed T,
) error

Execute will execute the request with the given instructions

func (*Request[T]) PatchAlways

func (r *Request[T]) PatchAlways() *Request[T]

PatchAlways will always try to attempt the patch of the retrieved resource with the proposed one

func (*Request[T]) WithCustomPatchConditions

func (r *Request[T]) WithCustomPatchConditions(conditions ...patchCondition[T]) *Request[T]

WithCustomPatchConditions will evaluate custom patch conditions

Jump to

Keyboard shortcuts

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