clientwrapper

package
v0.0.0-...-6ccfea3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: EPL-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectType

func GetObjectType(obj interface{}) string

Types

type ClientWrapper

type ClientWrapper interface {
	// Sync ensures that the object is up to date in the cluster.
	// Object is created if it does not exist and updated if it exists but is different.
	// Returns nil if object is in sync.
	Sync(ctx context.Context, blueprint client.Object, opts ...SyncOption) error
	// SyncStatus ensures that the status subresource of the object is up to date in the cluster.
	// Object must exist, otherwise an error is returned.
	// Returns nil if object is in sync.
	SyncStatus(ctx context.Context, blueprint client.Object, opts ...SyncOption) error
	// Create creates object.
	// Returns nil if object is created otherwise returns error.
	Create(ctx context.Context, blueprint client.Object, opts ...client.CreateOption) error
	// CreateIfNotExists creates object if not exists.
	// Returns nil if object is created or exists otherwise returns error.
	CreateIfNotExists(ctx context.Context, blueprint client.Object, opts ...client.CreateOption) error
	// GetIgnoreNotFound gets object.
	// Returns true if object exists otherwise returns false.
	// Returns nil if object is retrieved or not found otherwise returns error.
	GetIgnoreNotFound(ctx context.Context, key client.ObjectKey, objectMeta client.Object, opts ...client.GetOption) (bool, error)
	// DeleteByKeyIgnoreNotFound deletes object by key.
	// The object is fetched from the cluster first, so the object passed in
	// only needs to carry the type, not the actual content.
	// Returns nil if object is deleted or not found otherwise returns error.
	DeleteByKeyIgnoreNotFound(ctx context.Context, key client.ObjectKey, objectMeta client.Object, opts ...client.DeleteOption) error
	// DeleteAllOf deletes all objects of the given type.
	// Returns nil if objects are deleted otherwise returns error.
	DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
	// List returns list of runtime objects.
	// Returns nil if list is retrieved otherwise returns error.
	List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) ([]runtime.Object, error)
}

type K8sClientWrapper

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

func New

func New(cli client.Client, scheme *runtime.Scheme) *K8sClientWrapper

func (K8sClientWrapper) Create

func (k K8sClientWrapper) Create(
	ctx context.Context,
	obj client.Object,
	opts ...client.CreateOption,
) error

func (K8sClientWrapper) CreateIfNotExists

func (k K8sClientWrapper) CreateIfNotExists(
	ctx context.Context,
	obj client.Object,
	opts ...client.CreateOption,
) error

func (K8sClientWrapper) DeleteAllOf

func (k K8sClientWrapper) DeleteAllOf(
	ctx context.Context,
	obj client.Object,
	opts ...client.DeleteAllOfOption,
) error

func (K8sClientWrapper) DeleteByKeyIgnoreNotFound

func (k K8sClientWrapper) DeleteByKeyIgnoreNotFound(
	ctx context.Context,
	key client.ObjectKey,
	objectMeta client.Object,
	opts ...client.DeleteOption,
) error

func (K8sClientWrapper) GetIgnoreNotFound

func (k K8sClientWrapper) GetIgnoreNotFound(
	ctx context.Context,
	key client.ObjectKey,
	objectMeta client.Object,
	opts ...client.GetOption,
) (bool, error)

func (K8sClientWrapper) List

func (K8sClientWrapper) Sync

func (k K8sClientWrapper) Sync(
	ctx context.Context,
	obj client.Object,
	opts ...SyncOption,
) error

func (K8sClientWrapper) SyncStatus

func (k K8sClientWrapper) SyncStatus(
	ctx context.Context,
	obj client.Object,
	opts ...SyncOption,
) error

type SyncOption

type SyncOption interface {
	ApplyToSync(*SyncOptions)
}

type SyncOptions

type SyncOptions struct {
	// MergeLabels can be used to merge labels from existing object to the new one
	MergeLabels bool
	// MergeAnnotations can be used to merge annotations from existing object to the new one
	MergeAnnotations bool
	// PreserveFinalizers can be used to keep the finalizers of the existing object on update,
	// so that finalizers owned by other controllers are not stripped
	PreserveFinalizers bool
	// SuppressDiff can be used to suppress printing diff when object is not in sync
	SuppressDiff bool
	// DiffOpts can be used to customize comparison when object is not in sync
	DiffOpts []cmp.Option
	// DeleteOpts can be used to customize deletion when object is recreated
	DeleteOpts []client.DeleteOption
	// ForceRecreate deletes and re-creates the object instead of updating it when it is not in sync.
	// This applies to every kind, so it is caller's responsibility.
	ForceRecreate bool
}

func (*SyncOptions) ApplyOptions

func (o *SyncOptions) ApplyOptions(opts []SyncOption)

func (*SyncOptions) ApplyToSync

func (o *SyncOptions) ApplyToSync(so *SyncOptions)

type SyncTarget

type SyncTarget struct {
	Object   client.Object
	Key      types.NamespacedName
	DiffOpts []cmp.Option
}

Jump to

Keyboard shortcuts

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