kube

package
v0.0.0-...-66106be Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WriteToFile = clientcmd.WriteToFile

Functions

func Create

func Create[T any, PT AddrofObject[T]](ctx context.Context, ctl *Ctl, obj T) (*T, error)

Get is a generic equivalent of Ctl.Create.

func Delete

func Delete[T any, PT AddrofObject[T]](ctx context.Context, ctl *Ctl, key ObjectKey) error

Get is a generic equivalent of Ctl.Delete.

func Get

func Get[T any, PT AddrofObject[T]](ctx context.Context, ctl *Ctl, key ObjectKey) (*T, error)

Get is a generic equivalent of Ctl.Get.

func List

func List[T any, L ObjectList[T]](ctx context.Context, ctl *Ctl, opts ...client.ListOption) (*T, error)

List is a generic equivalent of [Ctl.List].

func RestToConfig

func RestToConfig(cfg *rest.Config) clientcmdapi.Config

Types

type AddrofObject

type AddrofObject[T any] interface {
	*T
	client.Object
}

AddrofObject is a helper type constraint for accepting a struct value that implements the Object interface.

type Ctl

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

Ctl is a Kubernetes client inspired by the shape of the `kubectl` CLI with a focus on being ergonomic.

func FromEnv

func FromEnv() (*Ctl, error)

FromEnv returns a Ctl for the default context in $KUBECONFIG.

func (*Ctl) Create

func (c *Ctl) Create(ctx context.Context, obj Object) error

func (*Ctl) Delete

func (c *Ctl) Delete(ctx context.Context, obj Object) error

func (*Ctl) Exec

func (c *Ctl) Exec(ctx context.Context, pod *corev1.Pod, opts ExecOptions) error

Exec runs `kubectl exec` on the given Pod in the style of [exec.Command].

func (*Ctl) Get

func (c *Ctl) Get(ctx context.Context, key ObjectKey, obj Object) error

Get fetches the latest state of an object into `obj` from Kubernetes. Usage:

var pod corev1.Pod
ctl.Get(ctx, kube.ObjectKey{Namespace: "", Name:""}, &pod)

func (*Ctl) RestConfig

func (c *Ctl) RestConfig() *rest.Config

RestConfig returns a deep copy of the rest.Config used by this Ctl.

type ExecOptions

type ExecOptions struct {
	Container string
	Command   []string
	Stdin     io.Reader
	Stdout    io.Writer
	Stderr    io.Writer
}

type Object

type Object = client.Object

type ObjectKey

type ObjectKey = client.ObjectKey

func AsKey

func AsKey(obj Object) ObjectKey

type ObjectList

type ObjectList[T any] interface {
	client.ObjectList
	*T
}

ObjectList is a generic equivalent of ObjectList.

type RESTConfig

type RESTConfig = rest.Config

Jump to

Keyboard shortcuts

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