Skip to content

Commit

Permalink
modify defaultKubeConfigPath
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr committed May 8, 2024
1 parent 5ee9938 commit d91755e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/kubernetes/kubernetes_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kubernetes
import (
"fmt"
"os"
"runtime"

"github.com/civo/cli/common"
"github.com/civo/cli/config"
Expand All @@ -26,8 +27,7 @@ Notes:
`

var saveConfig, switchConfig, overwriteConfig bool
var localPathConfig string
var defaultKubeConfigPath = "/.kube/config"
var localPathConfig, defaultKubeConfigPath string

var kubernetesConfigCmd = &cobra.Command{
Use: "config",
Expand Down Expand Up @@ -66,6 +66,12 @@ If you wish to use a custom format, the available fields are:
os.Exit(1)
}

if runtime.GOOS == "windows" {
defaultKubeConfigPath = os.Getenv("USERPROFILE") + "\\.kube\\config"
} else {
defaultKubeConfigPath = os.Getenv("HOME") + "/.kube/config"
}

if localPathConfig == "" { // Check if -p or --local-path argument was not provided
if os.Getenv("KUBECONFIG") != "" {
localPathConfig = os.Getenv("KUBECONFIG")
Expand Down

0 comments on commit d91755e

Please sign in to comment.