commandmanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandConfig

type CommandConfig struct {
	Command string
	Args    []string
	Sudo    bool
}

CommandConfig holds configurations for command execution.

type CommandManager

type CommandManager interface {
	// RunLocal executes a command on the local system.
	RunLocal(ctx context.Context, config CommandConfig) (CommandResult, error)

	// RunRemote executes a command on a remote system via SSH.
	RunRemote(ctx context.Context, config CommandConfig) (CommandResult, error)

	// Run executes a command on the local system if the host is localhost, otherwise it executes the command on the remote system.
	Run(ctx context.Context, config CommandConfig) (CommandResult, error)
}

CommandManager provides methods to execute commands, both locally and remotely.

type CommandResult

type CommandResult struct {
	STDOUT    string
	STDERR    string
	ExitCode  int
	Duration  time.Duration
	Command   string
	Timestamp time.Time
}

CommandResult encapsulates the results from a command execution.

type SSHDialer

type SSHDialer interface {
	Dial(network, addr string, config *ssh.ClientConfig, timeout time.Duration) (*ssh.Client, error)
}

type UnixCommandManager

type UnixCommandManager struct {
	Hostname  string
	SSHClient SSHDialer
	common.Credentials
}

func (*UnixCommandManager) Run

func (*UnixCommandManager) RunLocal

func (u *UnixCommandManager) RunLocal(ctx context.Context, config CommandConfig) (CommandResult, error)

func (*UnixCommandManager) RunRemote

func (u *UnixCommandManager) RunRemote(ctx context.Context, config CommandConfig) (CommandResult, error)

Jump to

Keyboard shortcuts

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