From f1ff8ef6f9c2abc6ca10b1f6308ed4225bbff2f4 Mon Sep 17 00:00:00 2001 From: Francisc Munteanu Date: Thu, 1 Aug 2024 14:28:24 +0200 Subject: [PATCH] use KUEBCOBFIG (#54) --- pkg/cmd/adm/register_member.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/adm/register_member.go b/pkg/cmd/adm/register_member.go index 5f44cfa..b60a479 100644 --- a/pkg/cmd/adm/register_member.go +++ b/pkg/cmd/adm/register_member.go @@ -81,7 +81,12 @@ func NewRegisterMemberCmd() *cobra.Command { } defaultKubeConfigPath := "" - if home := homedir.HomeDir(); home != "" { + + // first check if KUBECONFIG env variable is set + if kubeconfigPath := os.Getenv("KUBECONFIG"); kubeconfigPath != "" { + defaultKubeConfigPath = kubeconfigPath + } else if home := homedir.HomeDir(); home != "" { + // use home kubeconfig if no KUBECONFIG env var was set defaultKubeConfigPath = filepath.Join(home, ".kube", "config") }