Documentation
¶
Index ¶
- Constants
- type Manager
- func (m *Manager) AttachSession(sessionID string) (*sdkexec.Session, []byte, error)
- func (m *Manager) CloseSession(sessionID string) error
- func (m *Manager) DetachSession(sessionID string) (*sdkexec.Session, error)
- func (m *Manager) GetSession(sessionID string) (*sdkexec.Session, error)
- func (m *Manager) ListSessions(_ *types.PluginContext) []*sdkexec.Session
- func (m *Manager) ResizeSession(sessionID string, rows, cols uint16) error
- func (m *Manager) StartSession(pCtx *types.PluginContext, opts sdkexec.SessionOptions) (*sdkexec.Session, error)
- func (m *Manager) WriteSession(sessionID string, input []byte) error
- type OutputBuffer
- type Session
- type SessionDetails
- type SessionOptions
Constants ¶
const ( DefaultLocalShell = "/bin/zsh" DefaultReadBufferSize = 20480 InitialRows = 27 InitialCols = 72 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages terminal sessions, allowing creation, attachment, and more.
func NewManager ¶
func NewManager( log *zap.SugaredLogger, ) (*Manager, chan sdkexec.StreamInput, chan sdkexec.StreamOutput, chan sdkexec.StreamResize)
NewManager initializes a new Manager instance. Because we want to be a bit more latency sensitive with the local manager, we're going to directly return the channels for in and out that the exec controller will use.
func (*Manager) AttachSession ¶
AttachToSession marks a session as attached and returns its current output buffer.
func (*Manager) CloseSession ¶
CloseSession cancels the session's context, effectively terminating its command, and removes it from the manager.
func (*Manager) DetachSession ¶
DetachFromSession marks a session as not attached, stopping output broadcast.
func (*Manager) GetSession ¶
GetSession returns a session by its ID.
func (*Manager) ListSessions ¶
func (m *Manager) ListSessions(_ *types.PluginContext) []*sdkexec.Session
ListSessions returns a list of details for all active sessions.
func (*Manager) ResizeSession ¶
func (*Manager) StartSession ¶
func (m *Manager) StartSession( pCtx *types.PluginContext, opts sdkexec.SessionOptions, ) (*sdkexec.Session, error)
StartSession creates a new terminal session with a given command.
type OutputBuffer ¶
type OutputBuffer struct {
// contains filtered or unexported fields
}
OutputBuffer stores terminal output lines, providing a fixed-size cyclic buffer.
func NewOutputBuffer ¶
func NewOutputBuffer(capacity int) *OutputBuffer
NewOutputBuffer initializes an OutputBuffer with a specified capacity.
func (*OutputBuffer) Append ¶
func (b *OutputBuffer) Append(data []byte)
Append adds a line to the buffer, managing overflow by removing the oldest line.
func (*OutputBuffer) GetAll ¶
func (b *OutputBuffer) GetAll() []byte
GetAll retrieves a copy of all stored lines in the buffer.
type Session ¶
type Session struct { ID string // contains filtered or unexported fields }
Session represents an individual terminal session.
type SessionDetails ¶
type SessionDetails struct { // Labels are key-value pairs for the session. Labels map[string]string `json:"labels"` // ID is the unique identifier for the session. ID string `json:"id"` // Command is the command being run in the session. Command string `json:"command"` // Attached indicates if the session is currently broadcasting output. Attached bool `json:"attached"` }
SessionDetails contains details about a terminal session.
type SessionOptions ¶
type SessionOptions struct { ID string `json:"id"` // Labels are arbitrary key-value pairs for the session that can be used to filter sessions, or // to provide additional information about the session. Labels map[string]string `json:"labels"` // Kubeconfig is the path to the kubeconfig file. Kubeconfig string `json:"kubeconfig"` // Context is the name of the context to use. Context string `json:"context"` }
SessionOptions contains options for creating a new terminal session.