Skip to content

Commit

Permalink
Merge pull request #2 from mjhuber/check-kubeconfig-path
Browse files Browse the repository at this point in the history
Exit gracefully if kubeconfig doesn't exist in path provided.
  • Loading branch information
robscott committed Sep 11, 2018
2 parents 87cc034 + a5fbd48 commit 628f6ee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lookup/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ func getClientSet() (*kubernetes.Clientset, error) {
}
flag.Parse()


if _, err := os.Stat(kubeconfig); err != nil {
// kubeconfig doesn't exist
fmt.Printf("%s does not exist - please make sure you have a kubeconfig configured.\n", kubeconfig)
os.Exit(1)
}

// use the current context in kubeconfig
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
Expand Down

0 comments on commit 628f6ee

Please sign in to comment.