Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAttachHandler(path string) http.Handler
- func GenTerminalSessionId() (string, error)
- func WaitForNodeShellTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, nodeName string, ...)
- func WaitForTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, namespace string, ...)
- type PtyHandler
- type SessionMap
- type TerminalMessage
- type TerminalSession
Constants ¶
const END_OF_TRANSMISSION = "\u0004"
const SessionTerminalStoreTime = 5 // session timeout (minute)
Variables ¶
var TerminalSessions = SessionMap{Sessions: make(map[string]TerminalSession)}
Functions ¶
func CreateAttachHandler ¶
CreateAttachHandler is called from main for /api/sockjs
func GenTerminalSessionId ¶
func WaitForNodeShellTerminal ¶ added in v1.9.0
func WaitForNodeShellTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, nodeName string, sessionId string)
node shell
func WaitForTerminal ¶
func WaitForTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, namespace string, podName string, containerName string, sessionId string, shell string)
WaitForTerminal is called from apihandler.handleAttach as a goroutine Waits for the SockJS connection to be opened by the client the session to be Bound in handleTerminalSession
Types ¶
type PtyHandler ¶
type PtyHandler interface { io.Reader io.Writer remotecommand.TerminalSizeQueue }
PtyHandler is what remotecommand expects from a pty
type SessionMap ¶
type SessionMap struct { Sessions map[string]TerminalSession Lock sync.RWMutex }
SessionMap stores a map of all TerminalSession objects and a lock to avoid concurrent conflict
func (*SessionMap) Clean ¶ added in v1.6.0
func (sm *SessionMap) Clean()
Clean all session when system logout
func (*SessionMap) Close ¶
func (sm *SessionMap) Close(sessionId string, status uint32, reason string)
Close shuts down the SockJS connection and sends the status code and reason to the client 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 "")
func (*SessionMap) Get ¶
func (sm *SessionMap) Get(sessionId string) TerminalSession
Get return a given terminalSession by sessionId
func (*SessionMap) Set ¶
func (sm *SessionMap) Set(sessionId string, session TerminalSession)
Set store a TerminalSession to SessionMap
type TerminalMessage ¶
TerminalMessage is the messaging protocol between ShellController and TerminalSession.
OP DIRECTION FIELD(S) USED DESCRIPTION --------------------------------------------------------------------- bind fe->be SessionID Id sent back from TerminalResponse stdin fe->be Data Keystrokes/paste buffer resize fe->be Rows, Cols New terminal size stdout be->fe Data Output from the process toast be->fe Data OOB message to be shown to the user
type TerminalSession ¶
type TerminalSession struct { Id string Bound chan error SizeChan chan remotecommand.TerminalSize TimeOut time.Time // contains filtered or unexported fields }
TerminalSession implements PtyHandler (using a SockJS connection)
func (TerminalSession) Next ¶
func (t TerminalSession) Next() *remotecommand.TerminalSize
TerminalSize handles pty->process resize events Called in a loop from remotecommand as long as the process is running
func (TerminalSession) Read ¶
func (t TerminalSession) 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 (TerminalSession) Toast ¶
func (t TerminalSession) Toast(p string) error
Toast can be used to send the user any OOB messages hterm puts these in the center of the terminal