Skip to content

Commit

Permalink
Remove non used functions
Browse files Browse the repository at this point in the history
Signed-off-by: cmoulliard <[email protected]>
  • Loading branch information
cmoulliard committed Dec 11, 2024
1 parent 5830b22 commit d1ed81a
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions pkg/k8s/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

0 comments on commit d1ed81a

Please sign in to comment.