Skip to content

Commit

Permalink
Merge pull request #12 from mlbiam/master
Browse files Browse the repository at this point in the history
fix issue with multi-configfiles
  • Loading branch information
mlbiam authored Feb 10, 2021
2 parents adda338 + d0b9a41 commit 5d616b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export VERSION="0.0.5"
export VERSION="0.0.6"

rm -rf target
mkdir -p target
Expand Down
16 changes: 3 additions & 13 deletions kubectl-login.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"

Expand All @@ -39,7 +38,6 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/util/homedir"

"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -73,7 +71,7 @@ func randSeq(n int) string {
}

func main() {
fmt.Println("oulogin 0.0.5")
fmt.Println("oulogin 0.0.6")
host := flag.String("host", "", "openunison hostname (and port if needed)")

ctx := flag.String("context", "", "an existing context in the kubectl configuration file")
Expand Down Expand Up @@ -168,19 +166,11 @@ func checkCurrentConfig(host string, curCfg *api.Config) bool {
clientConfig := clientcmd.NewDefaultClientConfig(*curCfg, nil)
clientcmd.ModifyConfig(clientConfig.ConfigAccess(), *curCfg, false)

// reload and attempt to get the version to force a reload
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")
}
flag.Parse()

config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
config, err := clientConfig.ClientConfig()
if err != nil {
panic(err)
}

clientset, err := kubernetes.NewForConfig(config)
if err != nil {
panic(err)
Expand Down

0 comments on commit 5d616b1

Please sign in to comment.