Documentation
¶
Index ¶
- Variables
- func ServeSSH(ctx context.Context, opts Options, sshOpts SSHOptions) error
- type Command
- type CompletionContext
- type CompletionEngine
- type CompletionProvider
- type Func
- type GoroutineInfo
- type MemFS
- func (m *MemFS) Chmod(p string, mode fs.FileMode) error
- func (m *MemFS) Copy(src, dst string) error
- func (m *MemFS) Expose(procPath string, target any) error
- func (m *MemFS) List(p string) ([]fs.FileInfo, error)
- func (m *MemFS) Mkdir(p string) error
- func (m *MemFS) MountHost(mountPath, hostPath string, readOnly bool) error
- func (m *MemFS) Mounts() []MountInfo
- func (m *MemFS) OpenReader(p string) (io.ReadCloser, error)
- func (m *MemFS) OpenReaderContext(ctx context.Context, p string) (io.ReadCloser, error)
- func (m *MemFS) OpenWriter(p string, appendData bool) (io.WriteCloser, error)
- func (m *MemFS) ReadFile(p string) ([]byte, error)
- func (m *MemFS) ReadFileContext(ctx context.Context, p string) ([]byte, error)
- func (m *MemFS) Remove(p string) error
- func (m *MemFS) RemoveDir(p string) error
- func (m *MemFS) Rename(oldPath, newPath string) error
- func (m *MemFS) SetMaxBytes(max int64)
- func (m *MemFS) Stat(p string) (fs.FileInfo, error)
- func (m *MemFS) Touch(p string) error
- func (m *MemFS) Unexpose(procPath string) error
- func (m *MemFS) Unmount(mountPath string) error
- func (m *MemFS) WriteFile(p string, data []byte, appendData bool) error
- type MemReport
- type MetricSample
- type MountInfo
- type Options
- type ProcFS
- func (p *ProcFS) Expose(procPath string, target any) error
- func (p *ProcFS) List(path string) ([]fs.FileInfo, error)
- func (p *ProcFS) LogLevel() string
- func (p *ProcFS) OpenReaderContext(ctx context.Context, path string) (io.ReadCloser, error)
- func (p *ProcFS) Read(path string) ([]byte, error)
- func (p *ProcFS) ReadContext(ctx context.Context, path string) ([]byte, error)
- func (p *ProcFS) Stat(path string) (fs.FileInfo, error)
- func (p *ProcFS) Unexpose(procPath string) error
- func (p *ProcFS) Write(path string, data []byte) error
- type SSHOptions
- type Shell
- func (s *Shell) Commands() []Command
- func (s *Shell) Cwd() string
- func (s *Shell) EnableDangerous() bool
- func (s *Shell) Exec(ctx context.Context, line string) error
- func (s *Shell) FS() *MemFS
- func (s *Shell) Func(name string) (Func, bool)
- func (s *Shell) Run(ctx context.Context) error
- func (s *Shell) Version() string
- type StructFS
- func (s *StructFS) List(relPath string) ([]fs.FileInfo, error)
- func (s *StructFS) OpenReaderContext(_ context.Context, relPath string) (io.ReadCloser, error)
- func (s *StructFS) Read(relPath string) ([]byte, error)
- func (s *StructFS) Stat(relPath string) (fs.FileInfo, error)
- func (s *StructFS) Write(relPath string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrExitShell = errors.New("exit shell")
ErrExitShell signals that the shell should stop.
var ErrInterrupted = errors.New("line reader interrupted")
ErrInterrupted signals an interrupted interactive read (for example, Ctrl-C).
Functions ¶
Types ¶
type Command ¶
type Command struct {
Name string
Aliases []string
Usage string
Run func(ctx context.Context, sh *Shell, args []string, stdin io.Reader, stdout, stderr io.Writer) error
}
Command describes a shell command.
func DefaultCommands ¶
func DefaultCommands() []Command
DefaultCommands returns the built-in command set.
type CompletionContext ¶
type CompletionEngine ¶
type CompletionEngine struct {
// contains filtered or unexported fields
}
type CompletionProvider ¶
type CompletionProvider interface {
Complete(ctx CompletionContext, sh *Shell) []string
}
type Func ¶
Func is a registered Go function that can be invoked by the shell. The input is a JSON payload, and the returned value is rendered as JSON.
type GoroutineInfo ¶
type GoroutineInfo struct {
ID int `json:"id"`
State string `json:"state"`
Top string `json:"top"`
}
GoroutineInfo describes a goroutine summary.
type MemFS ¶
type MemFS struct {
// contains filtered or unexported fields
}
MemFS is a simple in-memory filesystem with optional proc-like pseudo files.
func (*MemFS) OpenReader ¶
func (m *MemFS) OpenReader(p string) (io.ReadCloser, error)
OpenReader returns a reader for a file path.
func (*MemFS) OpenReaderContext ¶
OpenReaderContext returns a reader for a file path with context support.
func (*MemFS) OpenWriter ¶
OpenWriter returns a writer that writes to a file path.
func (*MemFS) ReadFileContext ¶
ReadFileContext reads file contents, honoring context when supported.
func (*MemFS) SetMaxBytes ¶
SetMaxBytes limits the total size of files in the filesystem.
type MetricSample ¶
type MetricSample struct {
Name string `json:"name"`
Value any `json:"value"`
Unit string `json:"unit"`
}
MetricSample describes a runtime metric sample.
type Options ¶
type Options struct {
In io.Reader
Out io.Writer
Err io.Writer
Prompt string
Version string
EnableDangerous bool
FS *MemFS
Funcs map[string]Func
Commands []Command
Vars map[string]string
ScriptBindings map[string]map[string]any
}
Options configures a Shell.
type ProcFS ¶
type ProcFS struct {
// contains filtered or unexported fields
}
ProcFS exposes Go runtime data as pseudo files.
func (*ProcFS) OpenReaderContext ¶
OpenReaderContext opens a streaming reader for a proc path.
func (*ProcFS) ReadContext ¶
ReadContext reads a proc path with context-aware operations.
type SSHOptions ¶
type SSHOptions struct {
Addr string
HostKeySigner ssh.Signer
AuthorizedKeys []ssh.PublicKey
PasswordAuth func(ctx context.Context, user, pass string) bool
AllowPTY bool
}
SSHOptions configures the embedded SSH server.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell is an embedded runtime-aware shell.
func (*Shell) EnableDangerous ¶
type StructFS ¶
type StructFS struct {
// contains filtered or unexported fields
}
StructFS exposes a struct's fields and methods as files.
func NewStructFS ¶
NewStructFS creates a StructFS for a pointer to a struct.
func (*StructFS) OpenReaderContext ¶
OpenReaderContext opens a reader for a struct path.