package config

import (
	"path/filepath"

	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
)

var kubernetesConfig *rest.Config

func GetKubernetesConfig() *rest.Config {
	appConfig := GetConfig()
	kubeconfigPath := filepath.Join(appConfig.WorkDir, "k8s-admin.conf")

	kubernetesConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
	if err != nil {
		panic(err.Error())
	}
	return kubernetesConfig
}
