client

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultGroupVersionKind

func SetDefaultGroupVersionKind(obj Object, s *runtime.Scheme)

Types

type Object

type Object interface {
	runtime.Object
	metav1.Object
}

type ServerSideApplier

type ServerSideApplier struct {
	Scheme *runtime.Scheme
	// Owner becomes the Field Manager for whatever field the Server-Side apply acts on
	Owner k8scontrollerclient.FieldOwner
	// contains filtered or unexported fields
}

func NewFakeApplier

func NewFakeApplier(scheme *runtime.Scheme, owner string, objs ...runtime.Object) *ServerSideApplier

FakeApplier provides a wrapper around the fake k8s controller client to convert the unsupported apply-type patches to merge patches.

func NewForConfig

func NewForConfig(c *rest.Config, scheme *runtime.Scheme, owner string) (*ServerSideApplier, error)

func (*ServerSideApplier) Apply

func (c *ServerSideApplier) Apply(ctx context.Context, obj Object, changeFunc interface{}) func() error

Apply returns a function that invokes a change func on an object and performs a server-side apply patch with the result and its status subresource. The given resource must be a pointer to a struct that specifies its Name, Namespace, APIVersion, and Kind at minimum. The given change function must be unary, matching the signature: "func(<obj type>) error". The returned function is suitable for use w/ asyncronous assertions. The underlying value of the given resource pointer is updated to reflect the latest cluster state each time the closure is successfully invoked. Ex. Change the spec of an existing InstallPlan

plan := &InstallPlan{}
plan.SetNamespace("ns")
plan.SetName("install-123def")
Eventually(c.Apply(plan, func(p *v1alpha1.InstallPlan) error {
	p.Spec.Approved = true
	return nil
})).Should(Succeed())

Jump to

Keyboard shortcuts

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