client

package
v0.29.6 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericClient

type GenericClient[T client.Object, L client.ObjectList] interface {
	Reader[T, L]
	Writer[T]
	StatusClient[T]

	// Scheme returns the scheme this client is using.
	Scheme() *runtime.Scheme
	// RESTMapper returns the rest this client is using.
	RESTMapper() meta.RESTMapper
}

func NewGenericClient

func NewGenericClient[T client.Object, L client.ObjectList](
	cli client.Client,
	t T,
	l L,
) GenericClient[T, L]

func NewGenericClientFromConfig

func NewGenericClientFromConfig[T client.Object, L client.ObjectList](
	cfg *rest.Config,
	t T,
	l L,
) (GenericClient[T, L], error)

type Reader

type Reader[T client.Object, L client.ObjectList] interface {

	// Get retrieves an obj for the given object key from the Kubernetes Cluster.
	// obj must be a struct pointer so that obj can be updated with the response
	// returned by the Server.
	Get(ctx context.Context, key client.ObjectKey) (T, error)

	// List retrieves list of objects for a given namespace and list options. On a
	// successful call, Items field in the list will be populated with the
	// result returned from the server.
	List(ctx context.Context, opts ...client.ListOption) (L, error)
}

type StatusClient

type StatusClient[T client.Object] interface {
	Status() StatusWriter[T]
}

StatusClient knows how to create a client which can update status subresource for kubernetes objects.

type StatusWriter

type StatusWriter[T client.Object] interface {
	// Update updates the fields corresponding to the status subresource for the
	// given obj. obj must be a struct pointer so that obj can be updated
	// with the content returned by the Server.
	Update(ctx context.Context, obj T, opts ...client.UpdateOption) error

	// Patch patches the given object's subresource. obj must be a struct
	// pointer so that obj can be updated with the content returned by the
	// Server.
	Patch(ctx context.Context, obj T, patch client.Patch, opts ...client.PatchOption) error
}

StatusWriter knows how to update status subresource of a Kubernetes object.

type TransitionFunction

type TransitionFunction[T client.Object] func(existing, desired T) error

type Writer

type Writer[T client.Object] interface {
	// Create saves the object obj in the Kubernetes cluster.
	Create(ctx context.Context, obj T, opts ...client.CreateOption) error

	// Delete deletes the given obj from Kubernetes cluster.
	Delete(ctx context.Context, obj T, opts ...client.DeleteOption) error

	// Update updates the given obj in the Kubernetes cluster. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Update(ctx context.Context, obj T, opts ...client.UpdateOption) error

	// Patch patches the given obj in the Kubernetes cluster. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Patch(ctx context.Context, obj T, patch client.Patch, opts ...client.PatchOption) error

	// DeleteAllOf deletes all objects of the given type matching the given options.
	DeleteAllOf(ctx context.Context, obj T, opts ...client.DeleteAllOfOption) error

	// Create or Update the passed in object.
	Upsert(ctx context.Context, obj T, transitionFuncs ...TransitionFunction[T]) error
}

Jump to

Keyboard shortcuts

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