Skip to content

Commit

Permalink
Make locating kubeconfig in example os independent (argoproj#1393)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvwells authored and jessesuen committed Jun 5, 2019
1 parent 672dc04 commit 67714f9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/example-golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"os/user"
"path/filepath"

wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 67714f9

Please sign in to comment.