Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct {
OS string // 操作系统类型: alpine, ubuntu, centos, debian等
Architecture string // 架构: amd64, arm64等
IsAlpine bool // 是否为Alpine Linux
IsBusyBox bool // 是否基于BusyBox
IsDistroless bool // 是否为Distroless镜像
PackageManager string // 包管理器: apk, apt, yum等
ShellFeatures []string // 容器支持的shell特性
}
ContainerInfo 容器信息结构体 包含容器类型、操作系统等信息,用于优化shell选择
type Message ¶
type Message struct {
Op string `json:"op"` // 操作类型: stdin/resize/stdout
Data string `json:"data"` // 消息数据内容
RowSize uint16 `json:"row_size"` // 终端行数(resize操作使用)
ColSize uint16 `json:"col_size"` // 终端列数(resize操作使用)
}
WebSocket 消息协议定义:
OP DIRECTION USED DESCRIPTION --------------------------------------------------------------------- stdin fe->be Data 前端发送的键盘输入/粘贴缓冲区 resize fe->be RowSize, ColSize 前端发送的新终端尺寸 stdout be->fe Data 后端发送的进程输出
Message WebSocket消息结构体 定义了前后端通信的消息格式
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session 终端会话结构体 封装了WebSocket连接和终端大小变化通道
func (*Session) Next ¶
func (t *Session) Next() *remotecommand.TerminalSize
Next 实现remotecommand.TerminalSizeQueue接口 返回下一个终端大小变化,如果通道关闭则返回nil
type TerminalHandler ¶
type TerminalHandler interface {
// HandleSession 处理WebSocket终端会话
HandleSession(ctx context.Context, shell, namespace, podName, containerName string, conn *websocket.Conn)
}
TerminalHandler 定义终端处理接口
func NewTerminalHandler ¶
func NewTerminalHandler(client kubernetes.Interface, config *rest.Config, logger *zap.Logger) TerminalHandler
NewTerminalHandler 创建新的终端处理器 参数:
- client: Kubernetes客户端接口
- config: Kubernetes REST配置
- logger: 日志记录器
type TerminalSessionHandler ¶
type TerminalSessionHandler interface {
io.Reader
io.Writer
remotecommand.TerminalSizeQueue
}
TerminalSessionHandler 终端会话处理器接口 组合了io.Reader、io.Writer和终端大小队列接口
Click to show internal directories.
Click to hide internal directories.