未验证 提交 e7bb158e 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #1420 from wansir/kubectl

fix terminal resize
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand" "k8s.io/client-go/tools/remotecommand"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/simple/client" "kubesphere.io/kubesphere/pkg/simple/client"
"time" "time"
) )
...@@ -129,11 +130,7 @@ func (t TerminalSession) Toast(p string) error { ...@@ -129,11 +130,7 @@ func (t TerminalSession) Toast(p string) error {
// Can happen if the process exits or if there is an error starting up the process // Can happen if the process exits or if there is an error starting up the process
// For now the status code is unused and reason is shown to the user (unless "") // For now the status code is unused and reason is shown to the user (unless "")
func (t TerminalSession) Close(status uint32, reason string) { func (t TerminalSession) Close(status uint32, reason string) {
data, _ := json.Marshal(struct { klog.Warning(status, reason)
Status uint32 `json:"status"`
Reason string `json:"reason"`
}{Status: status, Reason: reason})
t.conn.WriteMessage(websocket.TextMessage, data)
t.conn.Close() t.conn.Close()
} }
...@@ -193,7 +190,7 @@ func HandleSession(shell, namespace, podName, containerName string, conn *websoc ...@@ -193,7 +190,7 @@ func HandleSession(shell, namespace, podName, containerName string, conn *websoc
var err error var err error
validShells := []string{"sh", "bash"} validShells := []string{"sh", "bash"}
session := &TerminalSession{conn: conn} session := &TerminalSession{conn: conn, sizeChan: make(chan remotecommand.TerminalSize)}
if isValidShell(validShells, shell) { if isValidShell(validShells, shell) {
cmd := []string{shell} cmd := []string{shell}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册