Skip to content

Commit ec5b7eb

Browse files
committed
make oc login kubeconfig permission error clearer
1 parent d6625c5 commit ec5b7eb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/cmd/cli/cmd/loginoptions.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,11 @@ func (o *LoginOptions) SaveConfig() (bool, error) {
394394
}
395395

396396
if err := kclientcmd.ModifyConfig(o.PathOptions, *configToWrite, true); err != nil {
397-
return false, err
397+
errorSuggestion := "Make sure that the --config flag passed contains the correct path:"
398+
if !o.PathOptions.IsExplicitFile() {
399+
errorSuggestion = "Make sure that your $KUBECONFIG variable is exported with the correct path:"
400+
}
401+
return false, fmt.Errorf("Failed to create kubeconfig under %s. %s %v\n", o.PathOptions.GetDefaultFilename(), errorSuggestion, err)
398402
}
399403

400404
created := false

0 commit comments

Comments
 (0)