conversion

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package conversion implements conversion utilities.

Index

Constants

View Source
const (
	// DataAnnotation is the annotation that conversion webhooks
	// use to retain the data in case of down-conversion from the hub.
	DataAnnotation = "cluster.x-k8s.io/conversion-data"
)

Variables

This section is empty.

Functions

func FuzzTestFunc

func FuzzTestFunc(input FuzzTestFuncInput) func(*testing.T)

FuzzTestFunc returns a new testing function to be used in tests to make sure conversions between the Hub version of an object and an older version aren't lossy.

func GetFuzzer

func GetFuzzer(scheme *runtime.Scheme, funcs ...fuzzer.FuzzerFuncs) *fuzz.Fuzzer

GetFuzzer returns a new fuzzer to be used for testing.

func MarshalData

func MarshalData(src metav1.Object, dst metav1.Object) error

MarshalData stores the source object as json data in the destination object annotations map. It ignores the metadata of the source object.

func UnmarshalData

func UnmarshalData(from metav1.Object, to interface{}) (bool, error)

UnmarshalData tries to retrieve the data from the annotation and unmarshals it into the object passed as input.

func UpdateReferenceAPIContract

func UpdateReferenceAPIContract(ctx context.Context, c client.Client, apiReader client.Reader, ref *corev1.ObjectReference) error

UpdateReferenceAPIContract takes a client and object reference, queries the API Server for the Custom Resource Definition and looks which one is the stored version available.

The object passed as input is modified in place if an updated compatible version is found. NOTE: In case CRDs are named incorrectly, this func is using an APIReader instead of the regular client to list CRDs to avoid implicitly creating an informer for CRDs which would lead to high memory consumption.

Types

type FuzzTestFuncInput

type FuzzTestFuncInput struct {
	Scheme *runtime.Scheme

	Hub              conversion.Hub
	HubAfterMutation func(conversion.Hub)

	Spoke                      conversion.Convertible
	SpokeAfterMutation         func(convertible conversion.Convertible)
	SkipSpokeAnnotationCleanup bool

	FuzzerFuncs []fuzzer.FuzzerFuncs
}

FuzzTestFuncInput contains input parameters for the FuzzTestFunc function.

Jump to

Keyboard shortcuts

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