Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyMetadata(fromAnnotations map[string]string, toAnnotations map[string]string, ...) (labels map[string]string, annotations map[string]string)
- func ConvertKindToResource(config *rest.Config, groupVersionKind schema.GroupVersionKind) (schema.GroupVersionResource, error)
- func ConvertLabelKeyWithPrefix(prefix, key string) string
- func EnsureCRDFromPhysicalCluster(ctx context.Context, pConfig *rest.Config, vConfig *rest.Config, ...) (bool, bool, error)
- func GetLoadBalancerSVCName(serviceName string) string
- func GetOwnerReference(object client.Object) []metav1.OwnerReference
- func KindExistsAndIsClusterScoped(config *rest.Config, groupVersionKind schema.GroupVersionKind) (bool, bool, error)
- func MergeLabelSelectors(elems ...*metav1.LabelSelector) *metav1.LabelSelector
- func ResetObjectMetadata(obj metav1.Object)
- func SafeConcatName(name ...string) string
- func Split(s, sep string) (string, string)
- func TranslateLabelSelectorWithPrefix(labelPrefix string, labelSelector *metav1.LabelSelector) *metav1.LabelSelector
- func UniqueSlice(stringSlice []string) []string
- type ApplyMapsOptions
- type PhysicalNameTranslator
- type PhysicalNamespacedNameTranslator
- type Translator
Constants ¶
View Source
const (
SkipBacksyncInMultiNamespaceMode = "vcluster.loft.sh/skip-backsync"
)
Variables ¶
View Source
var ( NamespaceLabel = "vcluster.loft.sh/namespace" MarkerLabel = "vcluster.loft.sh/managed-by" LabelPrefix = "vcluster.loft.sh/label" ControllerLabel = "vcluster.loft.sh/controlled-by" // Suffix is the vcluster name, usually set at start time Suffix = "suffix" ManagedAnnotationsAnnotation = "vcluster.loft.sh/managed-annotations" ManagedLabelsAnnotation = "vcluster.loft.sh/managed-labels" )
View Source
var ( NamespaceAnnotation = "vcluster.loft.sh/object-namespace" NameAnnotation = "vcluster.loft.sh/object-name" UIDAnnotation = "vcluster.loft.sh/object-uid" )
View Source
var Owner client.Object
Functions ¶
func ApplyMetadata ¶ added in v0.9.0
func ConvertKindToResource ¶ added in v0.14.0
func ConvertKindToResource(config *rest.Config, groupVersionKind schema.GroupVersionKind) (schema.GroupVersionResource, error)
func ConvertLabelKeyWithPrefix ¶ added in v0.5.0
func EnsureCRDFromPhysicalCluster ¶ added in v0.14.0
func GetLoadBalancerSVCName ¶ added in v0.14.2
GetLoadBalancerSVCName retrieves the service name if service name is set to type LoadBalancer. A separate service is created in this case so as to expose only the apiserver and not the kubelet port
func GetOwnerReference ¶ added in v0.4.4
func GetOwnerReference(object client.Object) []metav1.OwnerReference
func KindExistsAndIsClusterScoped ¶ added in v0.15.0
func KindExistsAndIsClusterScoped(config *rest.Config, groupVersionKind schema.GroupVersionKind) (bool, bool, error)
KindExistsAndIsClusterScoped checks if given CRDs exist in the given group. Returns foundKinds, notFoundKinds, error
func MergeLabelSelectors ¶ added in v0.5.0
func MergeLabelSelectors(elems ...*metav1.LabelSelector) *metav1.LabelSelector
func ResetObjectMetadata ¶
ResetObjectMetadata resets the objects metadata except name, namespace and annotations
func SafeConcatName ¶
func TranslateLabelSelectorWithPrefix ¶ added in v0.5.0
func TranslateLabelSelectorWithPrefix(labelPrefix string, labelSelector *metav1.LabelSelector) *metav1.LabelSelector
func UniqueSlice ¶
Types ¶
type ApplyMapsOptions ¶ added in v0.9.0
type PhysicalNameTranslator ¶ added in v0.4.0
PhysicalNameTranslator transforms a virtual cluster name to a physical name
type PhysicalNamespacedNameTranslator ¶ added in v0.14.0
type PhysicalNamespacedNameTranslator func(vNN types.NamespacedName, vObj client.Object) string
PhysicalNameTranslator transforms a virtual cluster name to a physical name
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 object is managed by vcluster IsManaged(obj runtime.Object) bool // IsManagedCluster checks if the cluster scoped object is managed by vcluster IsManagedCluster(obj runtime.Object) bool // IsTargetedNamespace checks if the provided namespace is a sync target for vcluster IsTargetedNamespace(ns string) bool // PhysicalNameClusterScoped returns the physical name for a cluster scoped // virtual cluster object PhysicalNameClusterScoped(vName string) string // PhysicalName returns the physical name for a virtual cluster object PhysicalName(vName, vNamespace string) string // PhysicalNamespace returns the physical namespace for a virtual cluster object PhysicalNamespace(vNamespace string) string // TranslateLabelsCluster translates the labels of a cluster scoped object TranslateLabelsCluster(vObj client.Object, pObj client.Object, syncedLabels []string) map[string]string // TranslateLabelSelectorCluster translates a label selector of a cluster scoped object TranslateLabelSelectorCluster(labelSelector *metav1.LabelSelector) *metav1.LabelSelector // ApplyMetadata translates the metadata including labels and annotations initially from virtual to physical ApplyMetadata(vObj client.Object, syncedLabels []string, excludedAnnotations ...string) client.Object // ApplyMetadataUpdate updates the physical objects metadata and signals if there were any changes ApplyMetadataUpdate(vObj client.Object, pObj client.Object, syncedLabels []string, excludedAnnotations ...string) (bool, map[string]string, map[string]string) // ApplyAnnotations applies the annotations from source to target ApplyAnnotations(src client.Object, to client.Object, excluded []string) map[string]string // ApplyLabels applies the labels from source to target ApplyLabels(src client.Object, to client.Object, syncedLabels []string) map[string]string // TranslateLabels translates labels TranslateLabels(fromLabels map[string]string, vNamespace string, syncedLabels []string) map[string]string // TranslateLabelSelector translates a label selector TranslateLabelSelector(labelSelector *metav1.LabelSelector) *metav1.LabelSelector // SetupMetadataWithName is similar to ApplyMetadata with a custom name translator and doesn't apply annotations and labels SetupMetadataWithName(vObj client.Object, translator PhysicalNameTranslator) (client.Object, error) // LegacyGetTargetNamespace returns in the case of a single namespace the target namespace, but fails // if vcluster is syncing to multiple namespaces. LegacyGetTargetNamespace() (string, error) ConvertLabelKey(string) string }
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
Click to show internal directories.
Click to hide internal directories.