Skip to content
Snippets Groups Projects
Commit d252456c authored by Jessica Yuen's avatar Jessica Yuen
Browse files

Gracefully handle error when kubeconfig not present

parent 11700746
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,12 @@ func resolveContext(context *string) (server, namespace string, err error) {
}
ctx := rawConfig.Contexts[ctxName]
if ctx == nil {
return "", "", fmt.Errorf("context '%s' does not exist in the kubeconfig file", *context)
if len(ctxName) == 0 && ctxName == rawConfig.CurrentContext {
// User likely does not have a kubeconfig file.
return "", "", fmt.Errorf("No current context found. Make sure a kubeconfig file is present")
}
return "", "", fmt.Errorf("context '%s' does not exist in the kubeconfig file", ctxName)
}
log.Infof("Using context '%s'", ctxName)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment