refactor: show shorten kubeconfig path (#722)

This commit is contained in:
naison
2025-09-30 16:28:17 +08:00
committed by GitHub
parent f4a0ab39f4
commit 00bcef1e49
2 changed files with 31 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/netip"
"net/url"
"os"
"path/filepath"
"strconv"
errors2 "github.com/pkg/errors"
@@ -26,7 +27,13 @@ import (
func GetKubeConfigPath(f cmdutil.Factory) string {
rawConfig := f.ToRawKubeConfigLoader()
if rawConfig.ConfigAccess().IsExplicitFile() {
return rawConfig.ConfigAccess().GetExplicitFile()
file := rawConfig.ConfigAccess().GetExplicitFile()
abs, err := filepath.Abs(file)
if err != nil {
return file
} else {
return abs
}
} else {
return rawConfig.ConfigAccess().GetDefaultFilename()
}