patcher

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PatchClient

type PatchClient[R runtime.Object] interface {
	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (R, error)
}

PatchClient is just the Patch API with a generic to keep use sites type safe. This is inspired by the commiter code in https://github.com/kcp-dev/kcp/blob/main/pkg/reconciler/committer/committer.go

type PatchOptions

type PatchOptions struct {
	// IgnoreResourceVersion will ignore the resource version matching when patching.
	IgnoreResourceVersion bool
}

type Patcher

type Patcher[R runtime.Object, Sp any, St any] interface {
	AddFinalizer(context.Context, R, ...string) (bool, error)
	RemoveFinalizer(context.Context, R, ...string) error
	PatchStatus(context.Context, R, St, St) (bool, error)
	PatchSpec(context.Context, R, Sp, Sp) (bool, error)
	PatchLabelAnnotations(context.Context, R, metav1.ObjectMeta, metav1.ObjectMeta) (bool, error)
	WithOptions(options PatchOptions) Patcher[R, Sp, St]
}

func NewPatcher

func NewPatcher[R runtime.Object, Sp any, St any](client PatchClient[R]) Patcher[R, Sp, St]

type Resource

type Resource[Sp any, St any] struct {
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              Sp `json:"spec"`
	Status            St `json:"status,omitempty"`
}

Resource is a generic wrapper around resources so we can generate patches.

Jump to

Keyboard shortcuts

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