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