Skip to content

Commit

Permalink
Merge pull request #590 from Jonsy13/config-fix
Browse files Browse the repository at this point in the history
Added litmusctl changes
  • Loading branch information
Jonsy13 authored Sep 18, 2024
2 parents f454e9e + 4defea4 commit 8a75d19
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions custom/litmus-helm-agent/pkg/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import (
"flag"
"fmt"
"os"
"path/filepath"

corev1r "k8s.io/api/core/v1"

metav1r "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
)

func ConnectKubeApi() *kubernetes.Clientset {
Expand Down Expand Up @@ -74,13 +72,12 @@ func CreateSecret(secretName string, secretData map[string][]byte, NAMESPACE str
}

func getKubeConfig() (*rest.Config, error) {
var kubeconfig *string
if home := homedir.HomeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
}
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
flag.Parse()
// Use in-cluster config if kubeconfig path is not specified
if *kubeconfig == "" {
return rest.InClusterConfig()
}

// use the current context in kubeconfig
return clientcmd.BuildConfigFromFlags("", *kubeconfig)
Expand Down

0 comments on commit 8a75d19

Please sign in to comment.