diff --git a/pkg/k8s/util.go b/pkg/k8s/util.go index 9c3ec13c..68b5366d 100644 --- a/pkg/k8s/util.go +++ b/pkg/k8s/util.go @@ -2,14 +2,9 @@ package k8s import ( "embed" - "fmt" "github.com/cnoe-io/idpbuilder/pkg/util" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/util/homedir" "os" - "path/filepath" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -62,30 +57,3 @@ func applyOverrides(filePath string, originalFiles [][]byte, scheme *runtime.Sch return ConvertYamlToObjectsWithOverride(scheme, originalFiles, rendered) } - -func GetKubeConfig(kubeConfigPath ...string) (*rest.Config, error) { - // Set default path if no path is provided - path := filepath.Join(homedir.HomeDir(), ".kube", "config") - - if len(kubeConfigPath) > 0 { - path = kubeConfigPath[0] - } - - kubeConfig, err := clientcmd.BuildConfigFromFlags("", path) - if err != nil { - return nil, fmt.Errorf("Error building kubeconfig from kind cluster: %w", err) - } - return kubeConfig, nil -} - -func GetKubeClient(kubeConfigPath ...string) (client.Client, error) { - kubeCfg, err := GetKubeConfig(kubeConfigPath...) - if err != nil { - return nil, fmt.Errorf("Error getting kubeconfig: %w", err) - } - kubeClient, err := client.New(kubeCfg, client.Options{Scheme: GetScheme()}) - if err != nil { - return nil, fmt.Errorf("Error creating kubernetes client: %w", err) - } - return kubeClient, nil -}