conversion

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAndRestore

func ConvertAndRestore[S, D metav1.Object](src S, dst D, compare S, convert func(S, D, conversion.Scope) error, unconvert func(D, S, conversion.Scope) error, srcRestorer RestorerFor[S], dstRestorer RestorerFor[D]) error

ConvertAndRestore converts src to dst. During conversion is reads and uses any restore data in the src annotation, and writes new restore data to the dst annotation.

Types

type HashedFieldRestorer

type HashedFieldRestorer[T any, F any] struct {
	// GetField returns the field to be restored
	GetField func(T) *F

	// FilterField returns a modified copy of the field to be used for comparison. i.e. filtered fields will be ignored in comparison.
	FilterField func(*F) *F

	// RestoreField restores the field to its original pre-conversion state
	RestoreField func(*F, *F)
}

HashedFieldRestorer restores a field to its original pre-conversion state only if it was not modified while converted. It does this by doing a full round-trip conversion before saving its state, and storing the hash of an unmodified round-trip converted object.

type RestorerFor

type RestorerFor[T metav1.Object] map[string]fieldRestorerFor[T]

RestorerFor holds all field restorers for a given type T.

type UnconditionalFieldRestorer

type UnconditionalFieldRestorer[T any, F any] struct {
	GetField func(T) *F
}

Jump to

Keyboard shortcuts

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