Fix the problem that the KUBECONFIG file does not exist (#476)

Co-authored-by: agent <agent@nuc>
This commit is contained in:
fj0r 2023-05-03 19:57:42 +08:00 committed by GitHub
parent 09647b77ee
commit 5b6d20d0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ def ensure-cache [cache path action] {
def "kube ctx" [] {
let cache = $'($env.HOME)/.cache/nu-power/kube.json'
let file = if ($env.KUBECONFIG? | is-empty) { $"($env.HOME)/.kube/config" } else { $env.KUBECONFIG }
if not ($file | path exists) { return $nothing }
ensure-cache $cache $file {
do -i {
kubectl config get-contexts
@ -26,10 +27,10 @@ def "kube ctx" [] {
def kube_stat [] {
{||
let ctx = (kube ctx)
let theme = $env.NU_POWER_THEME.kube
if ($ctx | is-empty) {
""
} else {
let theme = $env.NU_POWER_THEME.kube
let c = if $ctx.AUTHINFO == $ctx.CLUSTER {
$ctx.CLUSTER
} else {