Documentation ¶
Overview ¶
Package executor provides an interface for the executor as well as a local and remote implementation. The executor is used to run commands on the local machine or on a remote machine.
Index ¶
- func MakeOutAndErrWriters(hostAddr, hostName string, verbose bool, secrets []string) (outWr, errWr io.Writer)
- type ColorizedWriter
- type Connector
- type Dry
- func (ex *Dry) Close() error
- func (ex *Dry) Delete(_ context.Context, remoteFile string, recursive bool) (err error)
- func (ex *Dry) Download(_ context.Context, remote, local string, mkdir bool) (err error)
- func (ex *Dry) Run(_ context.Context, cmd string, verbose bool) (out []string, err error)
- func (ex *Dry) SetSecrets(secrets []string)
- func (ex *Dry) Sync(_ context.Context, localDir, remoteDir string, del bool) ([]string, error)
- func (ex *Dry) Upload(_ context.Context, local, remote string, mkdir bool) (err error)
- type Interface
- type Local
- func (l *Local) Close() error
- func (l *Local) Delete(_ context.Context, remoteFile string, recursive bool) (err error)
- func (l *Local) Download(_ context.Context, src, dst string, mkdir bool) (err error)
- func (l *Local) Run(ctx context.Context, cmd string, verbose bool) (out []string, err error)
- func (l *Local) SetSecrets(secrets []string)
- func (l *Local) Sync(ctx context.Context, src, dst string, del bool) ([]string, error)
- func (l *Local) Upload(_ context.Context, src, dst string, mkdir bool) (err error)
- type Remote
- func (ex *Remote) Close() error
- func (ex *Remote) Delete(ctx context.Context, remoteFile string, recursive bool) (err error)
- func (ex *Remote) Download(ctx context.Context, remote, local string, mkdir bool) (err error)
- func (ex *Remote) Run(ctx context.Context, cmd string, verbose bool) (out []string, err error)
- func (ex *Remote) SetSecrets(secrets []string)
- func (ex *Remote) Sync(ctx context.Context, localDir, remoteDir string, del bool) ([]string, error)
- func (ex *Remote) Upload(ctx context.Context, local, remote string, mkdir bool) (err error)
- type StdOutLogWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColorizedWriter ¶
type ColorizedWriter struct {
// contains filtered or unexported fields
}
ColorizedWriter is a writer that colorizes the output based on the hostAddr name.
func NewColorizedWriter ¶
func NewColorizedWriter(wr io.Writer, prefix, hostAddr, hostName string, secrets []string) *ColorizedWriter
NewColorizedWriter creates a new ColorizedWriter with the given hostAddr name.
func (*ColorizedWriter) WithHost ¶
func (s *ColorizedWriter) WithHost(hostAddr, hostName string) *ColorizedWriter
WithHost creates a new StdoutColorWriter with the given hostAddr name.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector provides factory methods to create Remote executor. Each executor is connected to a single SSH hostAddr.
func NewConnector ¶
NewConnector creates a new Connector for a given user and private key.
type Dry ¶
type Dry struct {
// contains filtered or unexported fields
}
Dry is an executor for dry run, just prints commands and files to be copied, synced, deleted. Useful for debugging and testing, doesn't actually execute anything.
func (*Dry) SetSecrets ¶
SetSecrets sets secrets for the executor
type Interface ¶
type Interface interface { SetSecrets(secrets []string) Run(ctx context.Context, c string, verbose bool) (out []string, err error) Upload(ctx context.Context, local, remote string, mkdir bool) (err error) Download(ctx context.Context, remote, local string, mkdir bool) (err error) Sync(ctx context.Context, localDir, remoteDir string, del bool) ([]string, error) Delete(ctx context.Context, remoteFile string, recursive bool) (err error) Close() error }
Interface is an interface for the executor. Implemented by Remote and Local structs.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a runner for local execution. Similar to remote, but without ssh, just exec on localhost and local copy/delete/sync
func (*Local) SetSecrets ¶
SetSecrets sets the secrets for the remote executor.
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote executes commands on remote server, via ssh. Not thread-safe.
func (*Remote) Delete ¶
Delete file on remote server. Recursively if recursive is true. if a file or directory does not exist, returns nil, i.e. no error.
func (*Remote) SetSecrets ¶
SetSecrets sets the secrets for the remote executor.
type StdOutLogWriter ¶
type StdOutLogWriter struct {
// contains filtered or unexported fields
}
StdOutLogWriter is a writer that writes to log with a prefix and a log level.
func NewStdoutLogWriter ¶
func NewStdoutLogWriter(prefix, level string, secrets []string) *StdOutLogWriter
NewStdoutLogWriter creates a new StdOutLogWriter.