package control

import (
	kubeclient "k8s.io/client-go/kubernetes"
	kubeclicmd "k8s.io/client-go/tools/clientcmd"
)

func MakeClientset(kubeconf []byte) (kubeclient.Interface, error) {
	var res kubeclient.Interface
	var err error
	clientConfig, err := kubeclicmd.NewClientConfigFromBytes(kubeconf)
	if err != nil {
		return res, err
	}
	restConfig, err := clientConfig.ClientConfig()
	if err != nil {
		return res, err
	}
	kubeClient, err := kubeclient.NewForConfig(restConfig)
	if err != nil {
		return res, err
	}
	res = kubeClient
	return res, err
}
