conversion

package
v0.0.0-...-40afb7c Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 27 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConversionController

func NewConversionController(
	ctx context.Context,
	path string,
	kinds map[schema.GroupKind]GroupKindConversion,
	withContext func(context.Context) context.Context,
) *controller.Impl

NewConversionController returns a K8s controller that will will reconcile CustomResourceDefinitions and update their conversion webhook attributes such as path & CA bundle.

Additionally the controller's Reconciler implements webhook.ConversionController for the purposes of converting resources between different versions

Types

type ConvertibleObject

type ConvertibleObject interface {
	// ConvertTo(ctx, to)
	// ConvertFrom(ctx, from)
	apis.Convertible

	// DeepCopyObject()
	// GetObjectKind() => SetGroupVersionKind(gvk)
	runtime.Object
}

ConvertibleObject defines the functionality our API types are required to implement in order to be convertible from one version to another

Optionally if the object implements apis.Defaultable the ConversionController will apply defaults before returning the response

type GroupKindConversion

type GroupKindConversion struct {
	// DefinitionName specifies the CustomResourceDefinition that should
	// be reconciled with by the controller.
	//
	// The conversion webhook configuration will be updated
	// when the CA bundle changes
	DefinitionName string

	// HubVersion specifies which version of the CustomResource supports
	// conversions to and from all types
	//
	// It is expected that the Zygotes map contains an entry for the
	// specified HubVersion
	HubVersion string

	// Zygotes contains a map of version strings (ie. v1, v2) to empty
	// ConvertibleObject objects
	//
	// During a conversion request these zygotes will be deep copied
	// and manipulated using the apis.Convertible interface
	Zygotes map[string]ConvertibleObject
}

GroupKindConversion specifies how a specific Kind for a given group should be converted

type OptionFunc

type OptionFunc func(*options)

func WithKinds

func WithKinds(kinds map[schema.GroupKind]GroupKindConversion) OptionFunc

func WithPath

func WithPath(path string) OptionFunc

func WithWrapContext

func WithWrapContext(f func(context.Context) context.Context) OptionFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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