From 3b9dcbe921571117fc809cd93da85751422f09b3 Mon Sep 17 00:00:00 2001 From: Ben Wells Date: Tue, 4 Jun 2019 18:33:47 +0100 Subject: [PATCH] Make locating kubeconfig in example os independent --- docs/example-golang/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/example-golang/main.go b/docs/example-golang/main.go index 29fc9ee6601b..1fd05e69f633 100644 --- a/docs/example-golang/main.go +++ b/docs/example-golang/main.go @@ -3,7 +3,7 @@ package main import ( "flag" "fmt" - "os" + "os/user" "path/filepath" wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" @@ -36,8 +36,12 @@ var ( ) func main() { - // use the current context in kubeconfig - kubeconfig := flag.String("kubeconfig", filepath.Join(os.Getenv("HOME"), ".kube", "config"), "(optional) absolute path to the kubeconfig file") + // get current user to determine home directory + usr, err := user.Current() + checkErr(err) + + // get kubeconfig file location + kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, ".kube", "config"), "(optional) absolute path to the kubeconfig file") flag.Parse() // use the current context in kubeconfig