v0.8.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 7 Imported by: 0



Package terminal implements the functions for all terminal interactions in the frontend. These includes to get a shell into a Pod, SSH sessions for a Node and the streaming of log files. The implementation is very similar to the implementation in the "Kubernetes Dashboard", you can find the file here: https://github.com/kubernetes/dashboard/blob/master/src/app/backend/handler/terminal.go



View Source
const END_OF_TRANSMISSION = "\u0004"


This section is empty.


func IsValidShell

func IsValidShell(shell string) bool

IsValidShell checks if the user provided shell is an allowed one.

func StartProcess

func StartProcess(config *rest.Config, reqURL *url.URL, cmd []string, ptyHandler PtyHandler) error

StartProcess executes the given command (cmd) in the container specified in the request and connects it up with the ptyHandler (a session).


type Message

type Message struct {
	Op, Data   string
	Rows, Cols uint16

Message is the messaging protocol between the shell and terminal session.

OP DIRECTION FIELD(S) USED DESCRIPTION --------------------------------------------------------------------- stdin fe->be Data Keystrokes/paste buffer resize fe->be Rows, Cols New terminal size stdout be->fe Data Output from the process

type PtyHandler

type PtyHandler interface {

PtyHandler is what remotecommand expects from a pty.

type Session

type Session struct {
	WebSocket *websocket.Conn
	SizeChan  chan remotecommand.TerminalSize
	DoneChan  chan struct{}

Session implements PtyHandler (using a WebSocket connection).

func (Session) Next

Next is called in a loop from remotecommand as long as the process is running. TerminalSize handles pty->process resize events.

func (Session) Read

func (t Session) Read(p []byte) (int, error)

Read handles pty->process messages (stdin, resize). Called in a loop from remotecommand as long as the process is running.

func (Session) Write

func (t Session) Write(p []byte) (int, error)

Write handles process->pty stdout. Called from remotecommand whenever there is any output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL