translator

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIfNil added in v0.14.0

func NewIfNil[T any, P interface {
	*T
	runtime.Object
}](updated, obj P) P

func PrintChanges added in v0.9.1

func PrintChanges(oldObject, newObject client.Object, log loghelper.Logger)

Types

type MetadataTranslator

type MetadataTranslator interface {
	// TranslateMetadata translates the object's metadata
	TranslateMetadata(ctx context.Context, vObj client.Object) client.Object

	// TranslateMetadataUpdate translates the object's metadata annotations and labels and determines
	// if they have changed between the physical and virtual object
	TranslateMetadataUpdate(ctx context.Context, vObj client.Object, pObj client.Object) (changed bool, annotations map[string]string, labels map[string]string)
}

MetadataTranslator is used to convert metadata between virtual and physical objects and vice versa

type NameTranslator

type NameTranslator interface {
	// IsManaged determines if a physical object is managed by the vcluster
	IsManaged(context.Context, client.Object) (bool, error)

	// VirtualToHost translates a virtual name to a physical name
	VirtualToHost(ctx context.Context, req types.NamespacedName, vObj client.Object) types.NamespacedName

	// HostToVirtual translates a physical name to a virtual name
	HostToVirtual(ctx context.Context, req types.NamespacedName, pObj client.Object) types.NamespacedName
}

NameTranslator is used to convert virtual to physical names and vice versa

type NamespacedTranslator

type NamespacedTranslator interface {
	Translator

	// EventRecorder returns
	EventRecorder() record.EventRecorder

	// RegisterIndices registers the default indices for the syncer
	RegisterIndices(ctx *syncercontext.RegisterContext) error

	// SyncToHostCreate creates the given pObj in the target namespace
	SyncToHostCreate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error)

	// SyncToHostUpdate updates the given pObj (if not nil) in the target namespace
	SyncToHostUpdate(ctx *syncercontext.SyncContext, vObj, pObj client.Object) (ctrl.Result, error)

	// SetNameTranslator is a function to override default VirtualToHost name translation
	SetNameTranslator(nameTranslator translate.PhysicalNamespacedNameTranslator)
}

NamespacedTranslator provides some helper functions to ease sync down translation

func NewNamespacedTranslator

func NewNamespacedTranslator(ctx *context.RegisterContext, name string, obj client.Object, excludedAnnotations ...string) NamespacedTranslator

type Translator

type Translator interface {
	Resource() client.Object
	Name() string
	NameTranslator
	MetadataTranslator
}

Translator is used to translate names as well as metadata between virtual and physical objects

func NewClusterTranslator

func NewClusterTranslator(ctx *context.RegisterContext, name string, obj client.Object, nameTranslator translate.PhysicalNameTranslator, excludedAnnotations ...string) Translator

func NewMirrorPhysicalTranslator

func NewMirrorPhysicalTranslator(name string, obj client.Object) Translator

Jump to

Keyboard shortcuts

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