ssh
v1.1.1
Documentation
pkg.go.dev ↗Package ssh provides an implemention of an Driver driver for executing jobs on.
Functions
Init
func Init(w io.Writer, cfg driver.Config) runner.Driver
Init initializes a new driver for SSH using the given io.Writer, and applying the given driver.Config.
Types
Config
type Config struct {
Addr string
User string
Password string
Timeout time.Duration
}
Config.Apply
func (cfg *Config) Apply(d runner.Driver)
Config.Merge
func (cfg *Config) Merge(m map[string]string) driver.Config
Driver
type Driver struct {
io.Writer
Addr string // Addr is the full address (including port) of the server.
User string // User is the user to use for SSH.
Password string // Password is the password to use for the SSH user.
Timeout time.Duration // Timeout is the duration for connection timeouts.
// contains filtered or unexported fields
}
Driver provides an implementation of the runner.Driver interface for SSH connections.
Driver.Create
func (s *Driver) Create(c context.Context, env []string, objs runner.Passthrough, p runner.Placer) error
Create opens up the Driver connection to the remote machine as configured via a previous call to Init. The given env slice is used to set an unexported variable for setting environment variables during job execution.
Driver.Destroy
func (s *Driver) Destroy()
Destroy closes the Driver connection.
Driver.Execute
func (s *Driver) Execute(j *runner.Job, c runner.Collector)
Execute will perform the given runner.Job. This turns it into a shell script that is executed on the remote machine once placed via SFTP. Before the job is executed however, the environment variables given via Create are set for the Driver session being used to invoke the script. The stderr, and stdout streams are forwarded to the underlying io.Writer.
Driver.PlaceObjects
func (s *Driver) PlaceObjects(objects runner.Passthrough, p runner.Placer) error
PlaceObjects copies the given objects from the given placer onto the environment via SFTP.