executor

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrPropSSHCommand is ErrPropSSHCommand
	ErrPropSSHCommand = errorx.RegisterPrintableProperty("ssh_command")
	// ErrPropSSHStdout is ErrPropSSHStdout
	ErrPropSSHStdout = errorx.RegisterPrintableProperty("ssh_stdout")
	// ErrPropSSHStderr is ErrPropSSHStderr
	ErrPropSSHStderr = errorx.RegisterPrintableProperty("ssh_stderr")

	// ErrSSHExecuteFailed is ErrSSHExecuteFailed
	ErrSSHExecuteFailed = errNSSSH.NewType("execute_failed")
	// ErrSSHExecuteTimedout is ErrSSHExecuteTimedout
	ErrSSHExecuteTimedout = errNSSSH.NewType("execute_timedout")
)

Functions

func FindSSHAuthorizedKeysFile added in v1.3.0

func FindSSHAuthorizedKeysFile(exec Executor) string

FindSSHAuthorizedKeysFile finds the correct path of SSH authorized keys file

Types

type EasySSHExecutor added in v1.0.9

type EasySSHExecutor struct {
	Config *easyssh.MakeConfig
	Locale string // the locale used when executing the command
	Sudo   bool   // all commands run with this executor will be using sudo
}

EasySSHExecutor implements Executor with EasySSH as transportation layer.

func (*EasySSHExecutor) Execute added in v1.0.9

func (e *EasySSHExecutor) Execute(cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error)

Execute run the command via SSH, it's not invoking any specific shell by default.

func (*EasySSHExecutor) Transfer added in v1.0.9

func (e *EasySSHExecutor) Transfer(src string, dst string, download bool) error

Transfer copies files via SCP This function depends on `scp` (a tool from OpenSSH or other SSH implementation) This function is based on easyssh.MakeConfig.Scp() but with support of copying file from remote to local.

type Executor added in v1.0.7

type Executor interface {
	// Execute run the command, then return it's stdout and stderr
	// NOTE: stdin is not supported as it seems we don't need it (for now). If
	// at some point in the future we need to pass stdin to a command, we'll
	// need to refactor this function and its implementations.
	// If the cmd can't quit in timeout, it will return error, the default timeout is 60 seconds.
	Execute(cmd string, sudo bool, timeout ...time.Duration) (stdout []byte, stderr []byte, err error)

	// Transfer copies files from or to a target
	Transfer(src string, dst string, download bool) error
}

Executor is the executor interface for TiUP, all tasks will in the end be passed to a executor and then be actually performed.

func New added in v1.2.0

func New(etype SSHType, sudo bool, c SSHConfig) (Executor, error)

New create a new Executor

type Local added in v1.1.0

type Local struct {
	Config *SSHConfig
	Sudo   bool   // all commands run with this executor will be using sudo
	Locale string // the locale used when executing the command
}

Local execute the command at local host.

func (*Local) Execute added in v1.1.0

func (l *Local) Execute(cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error)

Execute implements Executor interface.

func (*Local) Transfer added in v1.1.0

func (l *Local) Transfer(src string, dst string, download bool) error

Transfer implements Executer interface.

type NativeSSHExecutor added in v1.0.9

type NativeSSHExecutor struct {
	Config               *SSHConfig
	Locale               string // the locale used when executing the command
	Sudo                 bool   // all commands run with this executor will be using sudo
	ConnectionTestResult error  // test if the connection can be established in initialization phase
}

NativeSSHExecutor implements Excutor with native SSH transportation layer.

func (*NativeSSHExecutor) Execute added in v1.0.9

func (e *NativeSSHExecutor) Execute(cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error)

Execute run the command via SSH, it's not invoking any specific shell by default.

func (*NativeSSHExecutor) Transfer added in v1.0.9

func (e *NativeSSHExecutor) Transfer(src string, dst string, download bool) error

Transfer copies files via SCP This function depends on `scp` (a tool from OpenSSH or other SSH implementation)

type SSHConfig

type SSHConfig struct {
	Host       string // hostname of the SSH server
	Port       int    // port of the SSH server
	User       string // username to login to the SSH server
	Password   string // password of the user
	KeyFile    string // path to the private key file
	Passphrase string // passphrase of the private key file
	// Timeout is the maximum amount of time for the TCP connection to establish.
	Timeout time.Duration
}

SSHConfig is the configuration needed to establish SSH connection.

type SSHType added in v1.2.0

type SSHType string

SSHType represent the type of the chanel used by ssh

var (

	// SSHTypeBuiltin is the type of easy ssh executor
	SSHTypeBuiltin SSHType = "builtin"

	// SSHTypeSystem is the type of host ssh client
	SSHTypeSystem SSHType = "system"

	// SSHTypeNone is the type of local executor (no ssh will be used)
	SSHTypeNone SSHType = "none"
)

Jump to

Keyboard shortcuts

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