Skip to content

Commit

Permalink
Added litmusctl changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jonsy13 <vedant.shrotria@harness.io>
  • Loading branch information
Jonsy13 committed Sep 18, 2024
1 parent f454e9e commit 4defea4
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 4defea4

Please sign in to comment.