diff --git a/cmd/apply.go b/cmd/apply.go index f3fad98..6da6e82 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -30,7 +30,12 @@ var applyCmd = &cobra.Command{ opt.Namespace, _ = cmd.Flags().GetString("namespace") opt.TargetOwner, _ = cmd.Flags().GetString("target-owner") targetSecrets, _ := cmd.Flags().GetStringSlice("secrets") - kubeconfig := filepath.Join(os.Getenv("HOME"), ".kube", "config") + kubeconfig := "" + if os.Getenv("KUBECONFIG") == "" { + kubeconfig = filepath.Join(os.Getenv("HOME"), ".kube", "config") + } else { + kubeconfig = os.Getenv("KUBECONFIG") + } config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) if err != nil { log.Fatal(err) diff --git a/cmd/generate.go b/cmd/generate.go index 58b5c6e..37bb2fb 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -79,7 +79,12 @@ var generateCmd = &cobra.Command{ if opt.SecretStore && !opt.CopySecretRefs { log.Warnf("Warning! Backend Secret References are not being copied to the secret store namespaces! This could lead to unintended behavior (--secret-store=true --copy-secret-refs=false)") } - kubeconfig := filepath.Join(os.Getenv("HOME"), ".kube", "config") + kubeconfig := "" + if os.Getenv("KUBECONFIG") == "" { + kubeconfig = filepath.Join(os.Getenv("HOME"), ".kube", "config") + } else { + kubeconfig = os.Getenv("KUBECONFIG") + } config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) if err != nil { log.Fatal(err)