transforming

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTransformingWatcher

func NewTransformingWatcher(watcher watch.Interface, eventTransformer EventTransformer) *transformingWatcher

NewTransformingWatcher returns a watcher based on the input watcher, but which will apply the EventTransformer to each event before delivering it.

func WithResourceTransformer

func WithResourceTransformer(clusterClient kcpdynamic.ClusterInterface, transformer ResourceTransformer) kcpdynamic.ClusterInterface

WithResourceTransformer returns a ClusterInterface client whose kubernetes clients are wired with a ResourceTransformer.

Types

type EventTransformer

type EventTransformer func(event watch.Event) (transformed *watch.Event)

EventTransformer is a simple interface that transforms a watch event.

type ResourceInterfaceWithResults

type ResourceInterfaceWithResults interface {
	dynamic.ResourceInterface
	clientdynamic.DeleterWithResults
}

type ResourceTransformer

type ResourceTransformer interface {
	// BeforeWrite is called before a resource is created or updated. The resource effectively created or updated
	// sent to the kubernetes client is the transformed resource returned as result of this method call.
	BeforeWrite(client dynamic.ResourceInterface, ctx context.Context, gvr schema.GroupVersionResource, resource *unstructured.Unstructured, subresources ...string) (transformed *unstructured.Unstructured, err error)

	// AfterRead is called after a resource is returned from a kubernetes client call.
	// This includes Get and List calls, but also Create, and Update (since they return the created or updated resource).
	// It is also called for every resource associated to Watch Events in a Watch call.
	// In all those cases, the resource effectively read is the transformed resource returned as result of this method call.
	AfterRead(client dynamic.ResourceInterface, ctx context.Context, gvr schema.GroupVersionResource, resource *unstructured.Unstructured, eventType *watch.EventType, subresources ...string) (transformed *unstructured.Unstructured, err error)
}

ResourceTransformer define transformations that should be applied to a resource before and after a client submits a resource request to a kubernetes client.

Jump to

Keyboard shortcuts

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