mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-07-31 06:42:00 +00:00
Merge 6a33742edf
into 013b6bc252
This commit is contained in:
commit
43be8836fb
@ -15,6 +15,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -25,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func kubectxPrevCtxFile() (string, error) {
|
||||
home := cmdutil.HomeDir()
|
||||
home := cmp.Or(os.Getenv("KUBECTX_DIR"), cmdutil.HomeDir())
|
||||
if home == "" {
|
||||
return "", errors.New("HOME or USERPROFILE environment variable not set")
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -25,7 +26,7 @@ import (
|
||||
"github.com/ahmetb/kubectx/internal/cmdutil"
|
||||
)
|
||||
|
||||
var defaultDir = filepath.Join(cmdutil.HomeDir(), ".kube", "kubens")
|
||||
var defaultDir = filepath.Join(cmp.Or(os.Getenv("KUBECTX_DIR"), cmdutil.HomeDir()), ".kube", "kubens")
|
||||
|
||||
type NSFile struct {
|
||||
dir string
|
||||
|
@ -15,6 +15,7 @@
|
||||
package kubeconfig
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"github.com/ahmetb/kubectx/internal/cmdutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -68,7 +69,7 @@ func kubeconfigPath() (string, error) {
|
||||
}
|
||||
|
||||
// default path
|
||||
home := cmdutil.HomeDir()
|
||||
home := cmp.Or(os.Getenv("KUBECTX_DIR"), cmdutil.HomeDir())
|
||||
if home == "" {
|
||||
return "", errors.New("HOME or USERPROFILE environment variable not set")
|
||||
}
|
||||
|
3
kubectx
3
kubectx
@ -23,7 +23,8 @@ IFS=$'\n\t'
|
||||
|
||||
SELF_CMD="$0"
|
||||
|
||||
KUBECTX="${XDG_CACHE_HOME:-$HOME/.kube}/kubectx"
|
||||
[ -v KUBECTX_DIR ] && KUBECTX_DIR=${KUBECTX_DIR}/.kube/kubectx
|
||||
KUBECTX="${KUBECTX_DIR:-${XDG_CACHE_HOME:-$HOME/.kube}/kubectx}"
|
||||
|
||||
usage() {
|
||||
local SELF
|
||||
|
Loading…
Reference in New Issue
Block a user