func Convertor(syncerConfig *config.SyncerConfiguration, mcc mc.MultiClusterInterface) Conversion {
	return &objectConversion{config: syncerConfig, mcc: mcc}
}
Convertor implement the Conversion interface.
package conversion
import (
	"context"
	"crypto/sha256"
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"strings"
	"github.com/pkg/errors"
	v1 "k8s.io/api/core/v1"
	v1scheduling "k8s.io/api/scheduling/v1"
	storagev1 "k8s.io/api/storage/v1"
	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
	"k8s.io/apimachinery/pkg/api/meta"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/sets"
	"k8s.io/apimachinery/pkg/util/validation"
	v1core "k8s.io/client-go/kubernetes/typed/core/v1"
	listersv1 "k8s.io/client-go/listers/core/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/apis/tenancy/v1alpha1"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/apis/config"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/constants"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/util"
	"sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/syncer/util/featuregate"
	mc "sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/util/mccontroller"
)
func ToClusterKey(vc *v1alpha1.VirtualCluster) string {
	if vc.Status.ClusterNamespace != "" {
		return vc.Status.ClusterNamespace
	}
	digest := sha256.Sum256([]byte(vc.GetUID()))
	return vc.GetNamespace() + "-" + hex.EncodeToString(digest[0:])[0:6] + "-" + vc.GetName()
}
func ToSuperClusterNamespace(cluster, ns string) string {
	targetNamespace := strings.Join([]string{cluster, ns}, "-")
	if len(targetNamespace) > validation.DNS1123SubdomainMaxLength {
		digest := sha256.Sum256([]byte(targetNamespace))
		return targetNamespace[0:57] + "-" + hex.EncodeToString(digest[0:])[0:5]
	}
	return targetNamespace
}
func GetVirtualNamespace(nsLister listersv1.NamespaceLister, pNamespace string) (cluster, namespace string, err error) {
	vcInfo, err := nsLister.Get(pNamespace)
	if err != nil {
		return
	}
	if v, ok := vcInfo.GetAnnotations()[constants.LabelCluster]; ok {
		cluster = v
	}
	if v, ok := vcInfo.GetAnnotations()[constants.LabelNamespace]; ok {
		namespace = v
	}
	return
}
func GetVirtualOwner(meta client.Object) (cluster, namespace string) {
	cluster = meta.GetAnnotations()[constants.LabelCluster]
	namespace = meta.GetAnnotations()[constants.LabelNamespace]
	return cluster, namespace
}
func GetKubeConfigOfVC(c v1core.CoreV1Interface, vc *v1alpha1.VirtualCluster) ([]byte, error) {
	if adminKubeConfig, exists := vc.GetAnnotations()[constants.LabelAdminKubeConfig]; exists {
		decoded, err := base64.StdEncoding.DecodeString(adminKubeConfig)
		if err != nil {
			return nil, fmt.Errorf("failed to decode kubeconfig from annotations %s: %v", constants.LabelAdminKubeConfig, err)
		}
		return decoded, nil
	}
	secretName := constants.KubeconfigAdminSecretName
	secretFieldName := constants.KubeconfigAdminSecretName
	if adminKubeConfigName, exists := vc.GetAnnotations()[constants.LabelSecretAdminKubeConfig]; exists {
		secretName = adminKubeConfigName
		secretFieldName = "value"
	}
	clusterName := ToClusterKey(vc)
	adminKubeConfigSecret, err := c.Secrets(clusterName).Get(context.TODO(), secretName, metav1.GetOptions{})
	if err != nil {
		return nil, fmt.Errorf("failed to get secret (%s) for virtual cluster in root namespace %s: %v", constants.KubeconfigAdminSecretName, clusterName, err)
	}
	return adminKubeConfigSecret.Data[secretFieldName], nil
}
type objectConversion struct {
	config *config.SyncerConfiguration
	mcc    mc.MultiClusterInterface
}