Skip to content
Snippets Groups Projects
Unverified Commit e85c5a06 authored by Alex Clemmer's avatar Alex Clemmer Committed by GitHub
Browse files

Merge pull request #96 from jessicayuen/kubeconfig-missing

Gracefully handle error when kubeconfig not present
parents 722aa71f d252456c
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