conversion

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 20 Imported by: 31

Documentation

Overview

Package conversion provides implementation for CRD conversion webhook that implements handler for version conversion requests for types that are convertible.

See pkg/conversion for interface definitions required to ensure an API Type is convertible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConvertible

func IsConvertible(scheme *runtime.Scheme, obj runtime.Object) (bool, error)

IsConvertible determines if given type is convertible or not. For a type to be convertible, the group-kind needs to have a Hub type defined and all non-hub types must be able to convert to/from Hub.

func NewHubSpokeConverter added in v0.23.0

func NewHubSpokeConverter[hubObject runtime.Object](hub hubObject, spokeConverter ...SpokeConverter[hubObject]) func(scheme *runtime.Scheme) (Converter, error)

func NewWebhookHandler added in v0.15.0

func NewWebhookHandler(scheme *runtime.Scheme, registry Registry) http.Handler

Types

type Converter added in v0.23.0

type Converter interface {
	ConvertObject(ctx context.Context, src, dst runtime.Object) error
}

type Decoder

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

Decoder knows how to decode the contents of a CRD version conversion request into a concrete object. TODO(droot): consider reusing decoder from admission pkg for this.

func NewDecoder

func NewDecoder(scheme *runtime.Scheme) *Decoder

NewDecoder creates a Decoder given the runtime.Scheme

func (*Decoder) Decode

func (d *Decoder) Decode(content []byte) (runtime.Object, *schema.GroupVersionKind, error)

Decode decodes the inlined object.

func (*Decoder) DecodeInto

func (d *Decoder) DecodeInto(content []byte, into runtime.Object) error

DecodeInto decodes the inlined object in the into the passed-in runtime.Object.

type PartialImplementationError

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

PartialImplementationError represents an error due to partial conversion implementation such as hub without spokes, multiple hubs or spokes without hub.

func (PartialImplementationError) Error

type Registry added in v0.23.0

type Registry interface {
	RegisterConverter(gk schema.GroupKind, converter Converter) error
	GetConverter(gk schema.GroupKind) (Converter, bool)
}

func NewRegistry added in v0.23.0

func NewRegistry() Registry

type SpokeConverter added in v0.23.0

type SpokeConverter[hubObject runtime.Object] interface {
	GetSpoke() runtime.Object
	ConvertHubToSpoke(ctx context.Context, hub hubObject, spoke runtime.Object) error
	ConvertSpokeToHub(ctx context.Context, spoke runtime.Object, hub hubObject) error
}

func NewSpokeConverter added in v0.23.0

func NewSpokeConverter[hubObject, spokeObject client.Object](
	spoke spokeObject,
	convertHubToSpokeFunc func(ctx context.Context, src hubObject, dst spokeObject) error,
	convertSpokeToHubFunc func(ctx context.Context, src spokeObject, dst hubObject) error,
) SpokeConverter[hubObject]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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