ssh

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ssh provides an implemention of an Driver driver for executing jobs on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func 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

type Config

type Config struct {
	Addr     string
	User     string
	Password string
	Timeout  time.Duration
}

func (*Config) Apply

func (cfg *Config) Apply(d runner.Driver)

func (*Config) Merge

func (cfg *Config) Merge(m map[string]string) driver.Config

type 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.

func (*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.

func (*Driver) Destroy

func (s *Driver) Destroy()

Destroy closes the Driver connection.

func (*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.

func (*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.

Jump to

Keyboard shortcuts

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