translate

package
v0.21.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 29 Imported by: 7

Documentation

Index

Constants

View Source
const (
	SkipBackSyncInMultiNamespaceMode = "vcluster.loft.sh/skip-backsync"
)

Variables

View Source
var (
	NamespaceAnnotation     = "vcluster.loft.sh/object-namespace"
	NameAnnotation          = "vcluster.loft.sh/object-name"
	UIDAnnotation           = "vcluster.loft.sh/object-uid"
	KindAnnotation          = "vcluster.loft.sh/object-kind"
	HostNameAnnotation      = "vcluster.loft.sh/object-host-name"
	HostNamespaceAnnotation = "vcluster.loft.sh/object-host-namespace"
)
View Source
var (
	VClusterReleaseLabel = "release"
	NamespaceLabel       = "vcluster.loft.sh/namespace"
	MarkerLabel          = "vcluster.loft.sh/managed-by"
	ControllerLabel      = "vcluster.loft.sh/controlled-by"

	LabelPrefix          = "vcluster.loft.sh/label"
	NamespaceLabelPrefix = "vcluster.loft.sh/ns-label"

	// VClusterName is the vcluster name, usually set at start time
	VClusterName = "suffix"

	ManagedAnnotationsAnnotation = "vcluster.loft.sh/managed-annotations"
	ManagedLabelsAnnotation      = "vcluster.loft.sh/managed-labels"
)

Functions

func AnnotationsBidirectionalUpdate added in v0.21.0

func AnnotationsBidirectionalUpdate[T client.Object](event *synccontext.SyncEvent[T], excludedAnnotations ...string) (map[string]string, map[string]string)

func AnnotationsBidirectionalUpdateFunction added in v0.21.0

func AnnotationsBidirectionalUpdateFunction[T client.Object](event *synccontext.SyncEvent[T], transformFromHost, transformToHost func(key string, value interface{}) (string, interface{})) (map[string]string, map[string]string)

func ApplyMetadata added in v0.9.0

func ApplyMetadata(fromAnnotations map[string]string, toAnnotations map[string]string, fromLabels map[string]string, toLabels map[string]string, excludeAnnotations ...string) (labels map[string]string, annotations map[string]string)

func ConvertKindToResource added in v0.14.0

func ConvertKindToResource(config *rest.Config, groupVersionKind schema.GroupVersionKind) (schema.GroupVersionResource, error)

func CopyObjectWithName added in v0.21.0

func CopyObjectWithName[T client.Object](obj T, name types.NamespacedName, setOwner bool) T

func EnsureCRDFromPhysicalCluster added in v0.14.0

func EnsureCRDFromPhysicalCluster(ctx context.Context, pConfig *rest.Config, vConfig *rest.Config, groupVersionKind schema.GroupVersionKind) (bool, bool, error)

func GetOwnerReference added in v0.4.4

func GetOwnerReference(object client.Object) []metav1.OwnerReference

func HostAnnotations added in v0.21.0

func HostAnnotations(vObj, pObj client.Object, excluded ...string) map[string]string

func HostLabel added in v0.21.0

func HostLabel(vLabel string) string

func HostLabelNamespace added in v0.21.0

func HostLabelNamespace(key string) string

func HostLabelSelector added in v0.21.0

func HostLabelSelector(labelSelector *metav1.LabelSelector) *metav1.LabelSelector

func HostLabelSelectorNamespace added in v0.21.0

func HostLabelSelectorNamespace(labelSelector *metav1.LabelSelector) *metav1.LabelSelector

func HostLabels added in v0.21.0

func HostLabels(vObj, pObj client.Object) map[string]string

func HostLabelsMap added in v0.21.0

func HostLabelsMap(vLabels, pLabels map[string]string, vNamespace string, isMetadata bool) map[string]string

func HostMetadata added in v0.21.0

func HostMetadata[T client.Object](vObj T, name types.NamespacedName, excludedAnnotations ...string) T

func IsTranslatedLabel added in v0.21.0

func IsTranslatedLabel(label string) (string, bool)

func KindExists added in v0.14.0

func KindExists(config *rest.Config, groupVersionKind schema.GroupVersionKind) (metav1.APIResource, error)

KindExists returns the api resource for a given CRD. If the kind does not exist, it returns an error.

func LabelsBidirectionalUpdate added in v0.21.0

func LabelsBidirectionalUpdate[T client.Object](event *synccontext.SyncEvent[T], excludedLabels ...string) (map[string]string, map[string]string)

func LabelsBidirectionalUpdateFunction added in v0.21.0

func LabelsBidirectionalUpdateFunction[T client.Object](event *synccontext.SyncEvent[T], transformFromHost, transformToHost func(key string, value interface{}) (string, interface{})) (map[string]string, map[string]string)

func LabelsBidirectionalUpdateFunctionMaps added in v0.21.0

func LabelsBidirectionalUpdateFunctionMaps(virtualOld, virtual, hostOld, host map[string]string, transformFromHost, transformToHost func(key string, value interface{}) (string, interface{})) (map[string]string, map[string]string)

func LabelsBidirectionalUpdateMaps added in v0.21.0

func LabelsBidirectionalUpdateMaps(virtualOld, virtual, hostOld, host map[string]string, excludedLabels ...string) (map[string]string, map[string]string)

func MergeLabelSelectors added in v0.5.0

func MergeLabelSelectors(elems ...*metav1.LabelSelector) *metav1.LabelSelector

func ResetObjectMetadata

func ResetObjectMetadata(obj metav1.Object)

ResetObjectMetadata resets the objects metadata except name, namespace and annotations

func SafeConcatName

func SafeConcatName(name ...string) string

func SingleNamespaceHostName added in v0.21.0

func SingleNamespaceHostName(name, namespace, suffix string) string

func Split

func Split(s, sep string) (string, string)

func VirtualAnnotations added in v0.21.0

func VirtualAnnotations(pObj, vObj client.Object, excluded ...string) map[string]string

func VirtualLabel added in v0.21.0

func VirtualLabel(pLabel string) (string, bool)

func VirtualLabelSelector added in v0.21.0

func VirtualLabelSelector(labelSelector *metav1.LabelSelector) *metav1.LabelSelector

func VirtualLabels added in v0.21.0

func VirtualLabels(pObj, vObj client.Object) map[string]string

func VirtualLabelsMap added in v0.21.0

func VirtualLabelsMap(pLabels, vLabels map[string]string, excluded ...string) map[string]string

func VirtualMetadata added in v0.21.0

func VirtualMetadata[T client.Object](pObj T, name types.NamespacedName, excludedAnnotations ...string) T

Types

type ApplyMapsOptions added in v0.9.0

type ApplyMapsOptions struct {
	ManagedKeys []string
	ExcludeKeys []string
}

type Translator added in v0.4.4

type Translator interface {
	// SingleNamespaceTarget signals if we sync all objects into a single namespace
	SingleNamespaceTarget() bool

	// IsManaged checks if the host object is managed by vCluster
	IsManaged(ctx *synccontext.SyncContext, pObj client.Object) bool

	// IsTargetedNamespace checks if the provided namespace is a sync target for vcluster
	IsTargetedNamespace(ctx *synccontext.SyncContext, namespace string) bool

	// MarkerLabelCluster returns the marker label for the cluster scoped object
	MarkerLabelCluster() string

	// HostName returns the host name for a virtual cluster object
	HostName(ctx *synccontext.SyncContext, vName, vNamespace string) types.NamespacedName

	// HostNameShort returns the short host name for a virtual cluster object
	HostNameShort(ctx *synccontext.SyncContext, vName, vNamespace string) types.NamespacedName

	// HostNameCluster returns the host name for a cluster scoped
	// virtual cluster object
	HostNameCluster(vName string) string

	// HostNamespace returns the host namespace for a virtual cluster object
	HostNamespace(ctx *synccontext.SyncContext, vNamespace string) string

	// LabelsToTranslate are the labels that should be translated
	LabelsToTranslate() map[string]bool
}
var Default Translator = &singleNamespace{}

func NewMultiNamespaceTranslator added in v0.14.0

func NewMultiNamespaceTranslator(currentNamespace string) Translator

func NewSingleNamespaceTranslator added in v0.14.0

func NewSingleNamespaceTranslator(targetNamespace string) Translator

Jump to

Keyboard shortcuts

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