resources

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 8 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

func RetryAlways added in v1.17.3

func RetryAlways(_ error) bool

RetryAlways is a function that always returns true on any error encountered

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 PersistentVolumeClaimBuilder added in v1.17.4

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

PersistentVolumeClaimBuilder creates a fluent abstraction to interact with the kubernetes resources

func NewPersistentVolumeClaimBuilder added in v1.17.4

func NewPersistentVolumeClaimBuilder() *PersistentVolumeClaimBuilder

NewPersistentVolumeClaimBuilder instantiates an empty PersistentVolumeClaimBuilder

func NewPersistentVolumeClaimBuilderFromPVC added in v1.17.4

func NewPersistentVolumeClaimBuilderFromPVC(pvc *corev1.PersistentVolumeClaim) *PersistentVolumeClaimBuilder

NewPersistentVolumeClaimBuilderFromPVC instantiates a builder with an existing object

func (*PersistentVolumeClaimBuilder) BeginMetadata added in v1.17.4

BeginMetadata gets the metadata builder

func (*PersistentVolumeClaimBuilder) Build added in v1.17.4

Build returns the underlying object

func (*PersistentVolumeClaimBuilder) WithAccessModes added in v1.17.4

WithAccessModes adds the access modes to the object being build

func (*PersistentVolumeClaimBuilder) WithRequests added in v1.17.4

WithRequests adds the requests to the object being build

func (*PersistentVolumeClaimBuilder) WithSource added in v1.18.5

WithSource assigns the currently source to the underlying object

func (*PersistentVolumeClaimBuilder) WithSpec added in v1.17.4

WithSpec assigns the currently passed specs to the underlying object

func (*PersistentVolumeClaimBuilder) WithStorageClass added in v1.17.4

func (b *PersistentVolumeClaimBuilder) WithStorageClass(storageClass *string) *PersistentVolumeClaimBuilder

WithStorageClass adds the storageClass to the object being build

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

type ResourceMetadataBuilder added in v1.17.4

type ResourceMetadataBuilder[T any] struct {
	// contains filtered or unexported fields
}

ResourceMetadataBuilder creates a fluent abstraction to interact with the kubernetes resources

func NewResourceMetadataBuilder added in v1.17.4

func NewResourceMetadataBuilder[T any](objectMeta *metav1.ObjectMeta, parentBuilder T) *ResourceMetadataBuilder[T]

NewResourceMetadataBuilder makes a ResourceMetadataBuilder starting from the object metadata

func (*ResourceMetadataBuilder[T]) EndMetadata added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) EndMetadata() T

EndMetadata ends the metadata building framework

func (*ResourceMetadataBuilder[T]) WithAnnotations added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithAnnotations(maps ...map[string]string) *ResourceMetadataBuilder[T]

WithAnnotations adds annotations to the resource being built

func (*ResourceMetadataBuilder[T]) WithClusterInheritance added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithClusterInheritance(cluster *apiv1.Cluster) *ResourceMetadataBuilder[T]

WithClusterInheritance adds the cluster inherited data and ownership to the object

func (*ResourceMetadataBuilder[T]) WithHash added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithHash(hashValue string) *ResourceMetadataBuilder[T]

WithHash adds the hash to the resource being built

func (*ResourceMetadataBuilder[T]) WithLabels added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithLabels(maps ...map[string]string) *ResourceMetadataBuilder[T]

WithLabels adds labels to the resource being built

func (*ResourceMetadataBuilder[T]) WithNamespacedName added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithNamespacedName(name, namespace string) *ResourceMetadataBuilder[T]

WithNamespacedName adds a namespace and a name to the resource being built

func (*ResourceMetadataBuilder[T]) WithOwnership added in v1.17.4

func (builder *ResourceMetadataBuilder[T]) WithOwnership(
	controller metav1.ObjectMeta,
	controllerTypeMeta metav1.TypeMeta,
) *ResourceMetadataBuilder[T]

WithOwnership adds ownership to the resource being built

Jump to

Keyboard shortcuts

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