executor

package
v0.0.0-...-a8bc657 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandExecution

type CommandExecution struct {
	Command []string
	Cwd     string
	Env     map[string]string
	Sudo    bool
	// contains filtered or unexported fields
}

CommandExecution helps us build a command for running

func (*CommandExecution) Run

func (c *CommandExecution) Run() error

Run executes the command

func (*CommandExecution) Setenv

func (c *CommandExecution) Setenv(k, v string) *CommandExecution

Setenv sets an environment variable for the command execution

func (*CommandExecution) WithCwd

func (c *CommandExecution) WithCwd(cwd string) *CommandExecution

WithCwd sets the directory in which the command will execute

func (*CommandExecution) WithSudo

func (c *CommandExecution) WithSudo() *CommandExecution

WithSudo indicates that the command should be executed with sudo

type Executor

type Executor interface {
	Close() error

	Run(c *CommandExecution) error

	Put(dest string, length int, content io.Reader, mode os.FileMode) error
	Mkdir(dest string, mode os.FileMode) error
}

func NewSSH

func NewSSH(client *ssh.Client) Executor

type LocalhostExecutor

type LocalhostExecutor struct {
}

func (*LocalhostExecutor) Close

func (e *LocalhostExecutor) Close() error

func (*LocalhostExecutor) Mkdir

func (s *LocalhostExecutor) Mkdir(dest string, mode os.FileMode) error

func (*LocalhostExecutor) Put

func (s *LocalhostExecutor) Put(dest string, length int, content io.Reader, mode os.FileMode) error

func (*LocalhostExecutor) Run

type SSHExecutor

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

func (*SSHExecutor) Close

func (e *SSHExecutor) Close() error

func (*SSHExecutor) Mkdir

func (s *SSHExecutor) Mkdir(dest string, mode os.FileMode) error

SCPMkdir executes a mkdir against the SSH target, using SCP

func (*SSHExecutor) Put

func (s *SSHExecutor) Put(dest string, length int, content io.Reader, mode os.FileMode) error

SCPPut copies a file to the SSH target, using SCP

func (*SSHExecutor) Run

func (s *SSHExecutor) Run(cmd *CommandExecution) error

type Target

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

SSH holds an SSH client, and adds utilities like SCP functionality

func NewTarget

func NewTarget(executor Executor) *Target

NewTarget constructs a new target

func (*Target) Command

func (s *Target) Command(cmd ...string) *CommandExecution

Command builds a CommandExecution bound to the current SSH target

func (*Target) Exec

func (s *Target) Exec(cmd ...string) error

Exec executes a command against the SSH target

func (*Target) Mkdir

func (t *Target) Mkdir(dest string, mode os.FileMode) error

func (*Target) Put

func (t *Target) Put(dest string, length int, content io.Reader, mode os.FileMode) error

Jump to

Keyboard shortcuts

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