mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-02-03 20:39:39 -05:00
Merge pull request #135790 from 0x5457/fix/attach-reattach-message-missing-namespace
Fix missing namespace flag in attach reattach message Kubernetes-commit: c04907b02556add29458563b181d66aed6a11a51
This commit is contained in:
commit
3c2d5800e1
2 changed files with 6 additions and 5 deletions
|
|
@ -356,9 +356,9 @@ func (o *AttachOptions) reattachMessage(containerName string, rawTTY bool) strin
|
|||
return ""
|
||||
}
|
||||
if _, path := podcmd.FindContainerByName(o.Pod, containerName); strings.HasPrefix(path, "spec.ephemeralContainers") {
|
||||
return fmt.Sprintf("Session ended, the ephemeral container will not be restarted but may be reattached using '%s %s -c %s -i -t' if it is still running", o.CommandName, o.Pod.Name, containerName)
|
||||
return fmt.Sprintf("Session ended, the ephemeral container will not be restarted but may be reattached using '%s %s -c %s -n %s -i -t' if it is still running", o.CommandName, o.Pod.Name, containerName, o.Pod.Namespace)
|
||||
}
|
||||
return fmt.Sprintf("Session ended, resume using '%s %s -c %s -i -t' command when the pod is running", o.CommandName, o.Pod.Name, containerName)
|
||||
return fmt.Sprintf("Session ended, resume using '%s %s -c %s -n %s -i -t' command when the pod is running", o.CommandName, o.Pod.Name, containerName, o.Pod.Namespace)
|
||||
}
|
||||
|
||||
type terminalSizeQueueAdapter struct {
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ func TestReattachMessage(t *testing.T) {
|
|||
container: "bar",
|
||||
rawTTY: true,
|
||||
stdin: true,
|
||||
expected: "Session ended, resume using",
|
||||
expected: "Session ended, resume using 'kubectl foo -c bar -n test -i -t' command when the pod is running",
|
||||
},
|
||||
{
|
||||
name: "no stdin",
|
||||
|
|
@ -549,7 +549,7 @@ func TestReattachMessage(t *testing.T) {
|
|||
container: "debugger",
|
||||
rawTTY: true,
|
||||
stdin: true,
|
||||
expected: "Session ended, the ephemeral container will not be restarted",
|
||||
expected: "Session ended, the ephemeral container will not be restarted but may be reattached using 'kubectl foo -c debugger -n test -i -t' if it is still running",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
|
|
@ -558,7 +558,8 @@ func TestReattachMessage(t *testing.T) {
|
|||
StreamOptions: exec.StreamOptions{
|
||||
Stdin: test.stdin,
|
||||
},
|
||||
Pod: test.pod,
|
||||
CommandName: "kubectl",
|
||||
Pod: test.pod,
|
||||
}
|
||||
if msg := options.reattachMessage(test.container, test.rawTTY); test.expected == "" && msg != "" {
|
||||
t.Errorf("reattachMessage(%v, %v) = %q, want empty string", test.container, test.rawTTY, msg)
|
||||
|
|
|
|||
Loading…
Reference in a new issue