-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print warning when delete current context #42538
Conversation
/lgtm |
@@ -71,6 +71,10 @@ func runDeleteContext(out io.Writer, configAccess clientcmd.ConfigAccess, cmd *c | |||
return fmt.Errorf("cannot delete context %s, not in %s", name, configFile) | |||
} | |||
|
|||
if config.CurrentContext == name { | |||
fmt.Fprint(out, "warning: this removed your active context, use \"kubectl config use-context\" to select a different one\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to print the warning to stderr.
@adohe I think we should have a release note for this. |
0ff136b
to
a1ce3a3
Compare
@ymqytw comment addressed. ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, other LGTM
@@ -65,7 +65,7 @@ func (test deleteContextTest) run(t *testing.T) { | |||
pathOptions.EnvVar = "" | |||
|
|||
buf := bytes.NewBuffer([]byte{}) | |||
cmd := NewCmdConfigDeleteContext(buf, pathOptions) | |||
cmd := NewCmdConfigDeleteContext(buf, nil, pathOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be safer to pass in a io.writer
instead of nil. Otherwise, it will panic if we print some error message in the stderr in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable tome. Some defensive programming would be better here. Updated
a1ce3a3
to
8ebc6e9
Compare
/assign @ymqytw |
/lgtm |
/approve |
Anyone help to change the milestone to 1.6? |
This is not a launch blocker. Moving to next milestone. |
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: AdoHe, pwittrock, rootfs, ymqytw Needs approval from an approver in each of these OWNERS Files:
We suggest the following people: |
@k8s-bot kubemark e2e test this |
@k8s-bot cvm gce e2e test this |
/release-note |
@pwittrock Please help remove the |
@k8s-bot non-cri node e2e test this |
@fabianofranz Mind removing the do-not-merge label? |
@ymqytw sure, done. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 44119, 42538, 43802, 42336, 43396) |
Automatic merge from submit-queue |
mirror update to kubectl. fix #42012 @smarterclayton ptal.
Release Note: