Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added litmusctl changes #590

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading