shell

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shell runs Cloud Shell (§7.1): a short-lived container per user on the controller node, with synctl authenticated as that user through temporary credentials. The dashboard reaches it through exec.

Index

Constants

View Source
const TaskPrefix = "shell-"

TaskPrefix starts shell container task IDs.

Variables

View Source
var ErrUnavailable = errors.New("Cloud Shell needs the controller node to be connected")

ErrUnavailable means there is no node to run shells on.

Functions

This section is empty.

Types

type Config

type Config struct {
	Image string // with sh; curl, jq and git are welcome (default alpine)
	// Synctl is the synctl binary on the controller host, mounted into the
	// shell ("" leaves it out).
	Synctl string
	// Endpoint is the API address as seen from the shell container.
	Endpoint func() string
	// IdleTimeout stops shells nobody used for this long.
	IdleTimeout time.Duration
	// Node returns the node to run shells on (the controller node).
	Node func() (store.Node, bool)
}

Config of the shell containers.

type Credentials

type Credentials struct {
	AccessKeyID, Secret, SessionToken string
}

Credentials are what the shell signs requests with.

type Manager

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

func New

func New(gw *agentgw.Gateway, cfg Config, log *slog.Logger) *Manager

func (*Manager) Get

func (m *Manager) Get(userID string) (Session, bool)

Get returns a user's shell.

func (*Manager) Hooks

func (m *Manager) Hooks() agentgw.Hooks

Hooks follow the shell containers' state, and remove shells left over from before a controller restart.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run stops idle and expired shells until ctx ends.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, userID string, creds func() (Credentials, time.Time, error)) (Session, error)

Start runs (or returns) a user's shell. creds are fresh temporary credentials, used when a new container starts.

func (*Manager) Stop

func (m *Manager) Stop(userID string)

Stop removes a user's shell container (its home volume stays).

func (*Manager) Touch

func (m *Manager) Touch(userID string)

Touch records activity (a terminal opened).

type Session

type Session struct {
	UserID     string    `json:"-"`
	TaskID     string    `json:"taskId"`
	NodeID     string    `json:"-"`
	State      string    `json:"state"` // starting | running | failed
	Error      string    `json:"error,omitempty"`
	StartedAt  time.Time `json:"startedAt"`
	LastActive time.Time `json:"lastActive"`
	ExpiresAt  time.Time `json:"expiresAt"` // its credentials
}

Session is one user's shell.

Jump to

Keyboard shortcuts

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