mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
Merge pull request #135790 from 0x5457/fix/attach-reattach-message-missing-namespace
Fix missing namespace flag in attach reattach message
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user