command

package
v0.0.0-...-ac9018b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package command provides a uniform interface for executing commands on local and remote hosts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResult

type CommandResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

type Executor

type Executor interface {
	Exec(ctx context.Context, command string) (*CommandResult, error)
}

type LocalExecutor

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

func NewLocalExecutor

func NewLocalExecutor(config LocalExecutorConfig) *LocalExecutor

func (*LocalExecutor) Exec

func (e *LocalExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)

type LocalExecutorConfig

type LocalExecutorConfig struct {
	RunAsRoot bool
}

type MockExecutor

type MockExecutor struct {
	Rules []MockRule
}

func NewMockExecutor

func NewMockExecutor(rules []MockRule) *MockExecutor

func (*MockExecutor) Exec

func (e *MockExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)

type MockRule

type MockRule struct {
	// CommandContains is a string that must be present in the command for the rule to match.
	CommandContains string
	// Stdout is the simulated standard output.
	Stdout string
	// Stderr is the simulated standard error.
	Stderr string
	// ExitCode is the simulated exit code.
	ExitCode int
}

type RemoteExecutor

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

func NewRemoteExecutor

func NewRemoteExecutor(config RemoteExecutorConfig) *RemoteExecutor

func (*RemoteExecutor) Exec

func (e *RemoteExecutor) Exec(ctx context.Context, command string) (*CommandResult, error)

func (*RemoteExecutor) Shutdown

func (e *RemoteExecutor) Shutdown(ctx context.Context) error

func (*RemoteExecutor) Startup

func (e *RemoteExecutor) Startup(ctx context.Context) error

type RemoteExecutorConfig

type RemoteExecutorConfig struct {
	RunAsRoot bool
	Address   string `validate:"required"`
	Port      uint16 `validate:"required"`
	Username  string `validate:"required"`
	Password  string
}

Jump to

Keyboard shortcuts

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