k8s_client

package
v0.0.0-...-2c0259d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: EPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectType

func GetObjectType(obj interface{}) string

Types

type K8sClient

type K8sClient 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
	// Create creates object.
	// Returns nil if object is created otherwise returns error.
	Create(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.
	// 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
	// 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 NewK8sClient

func NewK8sClient(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) 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

type SyncOption

type SyncOption interface {
	ApplyToList(*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
	// 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
}

func (*SyncOptions) ApplyOptions

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

func (*SyncOptions) ApplyToList

func (o *SyncOptions) ApplyToList(so *SyncOptions)

Jump to

Keyboard shortcuts

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