mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Check for --kubeconfig
flag with embedded kubectl
(#5064)
* Check for kubeconfig flag Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
parent
df4147cd57
commit
4f36c82ff7
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rancher/k3s/pkg/server"
|
||||
@ -17,6 +18,13 @@ import (
|
||||
|
||||
func Main() {
|
||||
kubenv := os.Getenv("KUBECONFIG")
|
||||
for i, arg := range os.Args {
|
||||
if strings.HasPrefix(arg, "--kubeconfig=") {
|
||||
kubenv = strings.Split(arg, "=")[1]
|
||||
} else if strings.HasPrefix(arg, "--kubeconfig") && i+1 < len(os.Args) {
|
||||
kubenv = os.Args[i+1]
|
||||
}
|
||||
}
|
||||
if kubenv == "" {
|
||||
config, err := server.HomeKubeConfig(false, false)
|
||||
if _, serr := os.Stat(config); err == nil && serr == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user