conversion

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(
	apiConversion *apisv1alpha1.APIConversion,
	structuralSchemas map[string]*structuralschema.Structural,
) (map[string][]*CompiledRule, error)

Compile compiles conversion rules.

Types

type CRConverterFactory

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

CRConverterFactory instantiates converters that are capable of converting custom resources between different API versions. It supports CEL-based conversion rules from APIConversion resources and the "none" conversion strategy.

func NewCRConverterFactory

func NewCRConverterFactory(
	apiConversionInformer apisinformers.APIConversionClusterInformer,
	objectCELTransformationsTimeout time.Duration,
) *CRConverterFactory

NewCRConverterFactory returns a CRConverterFactory that supports APIConversion-based conversions and the "none" conversion strategy.

func (*CRConverterFactory) NewConverter

NewConverter returns the appropriate conversion.Converter based on the CRD. If the CRD identifies as for a "wildcard partial metadata request", the nop converter is used. Otherwise, it returns a CEL-based converter if there is an associated APIConversion, a nop converter if the strategy is "none", or an error otherwise.

type CompiledRule

type CompiledRule struct {
	// FromPath is an expression specifying the field in the source version, such as spec.firstName.
	FromPath string
	// FromFields is FromPath split by '.', with any leading '.' removed.
	FromFields []string
	// ToPath is an expression specifying the destination field in the target version, such as spec.name.first.
	ToPath string
	// ToFields is ToPath split by '.', with any leading '.' removed.
	ToFields []string
	// Program is a compiled set of instructions for a conversion transformation.
	Program cel.Program
}

CompiledRule contains the compiled cel.Program to convert a single field.

type Converter

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

func NewConverter

func NewConverter(
	crd *apiextensionsv1.CustomResourceDefinition,
	apiConversion *apisv1alpha1.APIConversion,
	objectCELTransformationsTimeout time.Duration,
) (*Converter, error)

func (*Converter) Convert

Jump to

Keyboard shortcuts

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