// SetupTest is utility function to create clients and controller
// This is used by bucket request and bucket access request unit tests
SetupTest is utility function to create clients and controller
This is used by bucket request and bucket access request unit tests
// SetupTest is utility function to create clients and controller // This is used by bucket request and bucket access request unit tests
func SetupTest(ctx context.Context) (bucketclientset.Interface, kubeclientset.Interface, *controller.ObjectStorageController) {
	config, err := func() (*rest.Config, error) {
		kubeConfig := os.Getenv("KUBECONFIG")
		if kubeConfig != "" {
			return clientcmd.BuildConfigFromFlags("", kubeConfig)
		}
		return rest.InClusterConfig()
	}()
	if err != nil {
		glog.Fatalf("Failed to create clients: %v", err)
	}
	kubeClient, err := kubeclientset.NewForConfig(config)
	if err != nil {
		glog.Fatalf("Failed to create Kubernetes client: %v", err)
	}
	client, err := bucketclientset.NewForConfig(config)
	if err != nil {
		glog.Fatalf("Failed to create ObjectStorage client: %v", err)
	}
	crdClientset, err := apiextensions.NewForConfig(config)
	if err != nil {
		glog.Fatalf("Failed to create CRD client: %v", err)
	}
	err = RegisterCRDs(ctx, crdClientset.CustomResourceDefinitions())
	if err != nil {
		glog.Fatalf("Failed to register CRDs: %v", err)
	}
	rateLimit := workqueue.NewMaxOfRateLimiter(
		workqueue.NewItemExponentialFailureRateLimiter(100*time.Millisecond, 600*time.Second),
		&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(10), 100)},
	)
	ctrl, err := controller.NewObjectStorageControllerWithClientset("controller-manager", "leader-lock", 40, rateLimit, kubeClient, client)
	if err != nil {
		glog.Fatalf("Failed to create ObjectStorage Controller: %v", err)
	}
	go ctrl.Run(ctx)
	return client, kubeClient, ctrl
}
func SetupTest ( ctx context . Context ) ( bucketclientset . Interface , kubeclientset . Interface , * controller . ObjectStorageController ) { config , err := func ( ) ( * rest . Config , error ) { kubeConfig := os . Getenv ( " " ) if kubeConfig != " " { return clientcmd . BuildConfigFromFlags ( " " , kubeConfig ) } return rest . InClusterConfig ( ) } ( ) if err != nil { glog . Fatalf ( " " , err ) } kubeClient , err := kubeclientset . NewForConfig ( config ) if err != nil { glog . Fatalf ( " " , err ) } client , err := bucketclientset . NewForConfig ( config ) if err != nil { glog . Fatalf ( " " , err ) } crdClientset , err := apiextensions . NewForConfig ( config ) if err != nil { glog . Fatalf ( " " , err ) } err = RegisterCRDs ( ctx , crdClientset . CustomResourceDefinitions ( ) ) if err != nil { glog . Fatalf ( " " , err ) } rateLimit := workqueue . NewMaxOfRateLimiter ( workqueue . NewItemExponentialFailureRateLimiter ( 100 * time . Millisecond , 600 * time . Second ) , & workqueue . BucketRateLimiter { Limiter : rate . NewLimiter ( rate . Limit ( 10 ) , 100 ) } , ) ctrl , err := controller . NewObjectStorageControllerWithClientset ( " " , " " , 40 , rateLimit , kubeClient , client ) if err != nil { glog . Fatalf ( " " , err ) } go ctrl . Run ( ctx ) return client , kubeClient , ctrl }
SetupTest is utility function to create clients and controller
This is used by bucket request and bucket access request unit tests
SetupTest is utility function to create clients and controller This is used by bucket request and bucket access request unit tests
// Initialize the clients