Documentation
¶
Index ¶
- Constants
- func CreateAttachHandler(path string) http.Handler
- func WaitForTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, ...)
- type PtyHandler
- type SessionMap
- type SocketConfig
- type TerminalMessage
- type TerminalSession
- type TerminalSessionHandler
- type TerminalSessionHandlerImpl
- func (impl *TerminalSessionHandlerImpl) AutoSelectShell(req *TerminalSessionRequest) (string, error)
- func (impl *TerminalSessionHandlerImpl) Close(sessionId string, statusCode uint32, msg string)
- func (impl *TerminalSessionHandlerImpl) GetTerminalSession(req *TerminalSessionRequest) (statusCode int, message *TerminalMessage, err error)
- func (impl *TerminalSessionHandlerImpl) RunCmdInRemotePod(req *TerminalSessionRequest, cmds []string) (*bytes.Buffer, *bytes.Buffer, error)
- func (impl *TerminalSessionHandlerImpl) ValidateSession(sessionId string) bool
- func (impl *TerminalSessionHandlerImpl) ValidateShell(req *TerminalSessionRequest) (bool, error)
- type TerminalSessionRequest
Constants ¶
const ( SessionTerminated = "SessionTerminated" SessionInitiating = "SessionInitiating" )
const CommandExecutionFailed = "Failed to Execute Command"
const END_OF_TRANSMISSION = "\u0004"
const PodNotFound = "Pod NotFound"
const ProcessExitedMsg = "Process exited"
const ProcessTimedOut = "Process timedOut"
Variables ¶
This section is empty.
Functions ¶
func CreateAttachHandler ¶
CreateAttachHandler is called from main for /api/sockjs
func WaitForTerminal ¶
func WaitForTerminal(k8sClient kubernetes.Interface, cfg *rest.Config, request *TerminalSessionRequest)
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) 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
func (*SessionMap) SetTerminalSessionStartTime ¶ added in v0.7.0
func (sm *SessionMap) SetTerminalSessionStartTime(sessionId string)
type SocketConfig ¶ added in v0.6.28
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 {
// 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
type TerminalSessionHandler ¶
type TerminalSessionHandler interface {
GetTerminalSession(req *TerminalSessionRequest) (statusCode int, message *TerminalMessage, err error)
Close(sessionId string, statusCode uint32, msg string)
ValidateSession(sessionId string) bool
ValidateShell(req *TerminalSessionRequest) (bool, error)
AutoSelectShell(req *TerminalSessionRequest) (string, error)
RunCmdInRemotePod(req *TerminalSessionRequest, cmds []string) (*bytes.Buffer, *bytes.Buffer, error)
}
type TerminalSessionHandlerImpl ¶
type TerminalSessionHandlerImpl struct {
ClusterReadService read.ClusterReadService
// contains filtered or unexported fields
}
func NewTerminalSessionHandlerImpl ¶
func NewTerminalSessionHandlerImpl(environmentService environment.EnvironmentService, logger *zap.SugaredLogger, k8sUtil *k8s.K8sServiceImpl, ephemeralContainerService cluster.EphemeralContainerService, argoApplicationConfigService config.ArgoApplicationConfigService, ClusterReadService read.ClusterReadService, asyncRunnable *async.Runnable) *TerminalSessionHandlerImpl
func (*TerminalSessionHandlerImpl) AutoSelectShell ¶ added in v0.6.15
func (impl *TerminalSessionHandlerImpl) AutoSelectShell(req *TerminalSessionRequest) (string, error)
func (*TerminalSessionHandlerImpl) Close ¶ added in v0.6.10
func (impl *TerminalSessionHandlerImpl) Close(sessionId string, statusCode uint32, msg string)
func (*TerminalSessionHandlerImpl) GetTerminalSession ¶
func (impl *TerminalSessionHandlerImpl) GetTerminalSession(req *TerminalSessionRequest) (statusCode int, message *TerminalMessage, err error)
func (*TerminalSessionHandlerImpl) RunCmdInRemotePod ¶ added in v0.6.19
func (impl *TerminalSessionHandlerImpl) RunCmdInRemotePod(req *TerminalSessionRequest, cmds []string) (*bytes.Buffer, *bytes.Buffer, error)
func (*TerminalSessionHandlerImpl) ValidateSession ¶ added in v0.6.10
func (impl *TerminalSessionHandlerImpl) ValidateSession(sessionId string) bool
func (*TerminalSessionHandlerImpl) ValidateShell ¶ added in v0.6.15
func (impl *TerminalSessionHandlerImpl) ValidateShell(req *TerminalSessionRequest) (bool, error)
type TerminalSessionRequest ¶
type TerminalSessionRequest struct {
Shell string
SessionId string
Namespace string
PodName string
ContainerName string
//ApplicationId is helm app Id
ApplicationId string
EnvironmentId int
AppId int
//ClusterId is optional
ClusterId int
UserId int32
ExternalArgoApplicationName string
ExternalArgoApplicationNamespace string
ExternalArgoAppIdentifier *bean3.ArgoAppIdentifier
}