terminal

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package terminal provides WebSocket-based terminal access to deployed service containers. **Validates: Requirements 23.1, 23.2**

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceNotRunning is returned when attempting to connect to a non-running service.
	ErrServiceNotRunning = errors.New("service is not running")
	// ErrContainerNotFound is returned when the container cannot be found.
	ErrContainerNotFound = errors.New("container not found")
	// ErrSessionClosed is returned when the terminal session is closed.
	ErrSessionClosed = errors.New("terminal session closed")
)

Functions

func GenerateContainerName

func GenerateContainerName(appName, serviceName string, version int) string

GenerateContainerName creates a container name from app, service, and version. Format: {app}-{service}-v{version} **Validates: Requirements 9.3, 9.4, 9.5**

Types

type Config

type Config struct {
	// DefaultShell is the shell to use when connecting to containers.
	// Defaults to "/bin/sh" for BusyBox compatibility.
	// **Validates: Requirements 23.6**
	DefaultShell string
}

Config holds configuration for the terminal service.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default terminal service configuration.

type ControlMessage

type ControlMessage struct {
	Type string `json:"type"` // "resize" or "terminate"
	Rows uint16 `json:"rows,omitempty"`
	Cols uint16 `json:"cols,omitempty"`
}

ControlMessage represents a control message from the WebSocket client.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides terminal access to deployed containers. **Validates: Requirements 23.1, 23.2**

func NewService

func NewService(st store.Store, pd *podman.Client, cfg *Config, logger *slog.Logger) *Service

NewService creates a new terminal service.

func (*Service) ActiveSessions

func (s *Service) ActiveSessions() int

ActiveSessions returns the number of active terminal sessions.

func (*Service) CloseSession

func (s *Service) CloseSession(sessionID string) error

CloseSession closes a session by ID.

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, appID, serviceName string, conn *websocket.Conn) (*Session, error)

Connect establishes a terminal session to a container. **Validates: Requirements 23.1, 23.2**

func (*Service) GetSession

func (s *Service) GetSession(sessionID string) (*Session, bool)

GetSession returns an active session by ID.

func (*Service) HandleSession

func (s *Service) HandleSession(session *Session) error

HandleSession manages the bidirectional communication for a terminal session. **Validates: Requirements 23.1, 23.2, 23.5**

type Session

type Session struct {
	ID            string
	DeploymentID  string
	ContainerName string
	PTY           *os.File
	Conn          *websocket.Conn
	// contains filtered or unexported fields
}

Session represents an active terminal session.

func (*Session) Close

func (s *Session) Close() error

Close closes the terminal session and cleans up resources.

func (*Session) IsClosed

func (s *Session) IsClosed() bool

IsClosed returns true if the session is closed.

Jump to

Keyboard shortcuts

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