translate

package
v0.21.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 26 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 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

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

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

func HostLabel

func HostLabel(vLabel string) string

func HostLabelNamespace

func HostLabelNamespace(key string) string

func HostLabelSelector

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

func HostLabelSelectorNamespace

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

func HostLabels

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

func HostLabelsMap

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

func HostMetadata

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

func IsTranslatedLabel

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 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

func SingleNamespaceHostName(name, namespace, suffix string) string

func Split

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

func VirtualAnnotations

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

func VirtualLabel

func VirtualLabel(pLabel string) (string, bool)

func VirtualLabelSelector

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

func VirtualLabels

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

func VirtualLabelsMap

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

func VirtualMetadata

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