ssh

package
v0.0.0-...-141d866 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingDestination is a returned when the plugin is missing the destination parameter.
	ErrMissingDestination = errors.New("missing destination parameter")

	// ErrMissingCommand is a returned when the plugin is missing the command parameter.
	ErrMissingCommand = errors.New("missing command parameter")
)

Functions

This section is empty.

Types

type Config

type Config struct {

	// Command is a required parameter containing all of the commands
	// to execute on the remote system
	Command []string

	// Destination is the machine where the plugin will execute the command.
	Destination string

	// IdentityFilePath is the path to the identity file to use
	// for authenticating against remote systems. You can specify
	// multiple files to use each one in turn if needed.
	IdentityFilePath []string

	// IdentityFileContents is a string representation of an identity
	// file. This is used since the plugin needs to consume secrets
	// and those sometimes come through as environmental variables
	// so we'll need to take the raw contents and place them into a file
	// so that the binaries later can use them.
	IdentityFileContents string

	// SSHFlags is for setting or overriding any sort of SSH features.
	SSHFlags []string

	// SSHPassword is used for authenticating against systems with a password
	// instead of an identity file. Since this is passed to sshpass it's
	// limited to only one password for whatever remote systems are in use.
	// Prefer to use identity files if possible since you can specify quite a bit more.
	SSHPassword string

	// SSHPassphrase is used for the identity files specified. Just like with SSHPassword
	// this is handed off to sshpass to use in authentication and it only supports
	// one parameter, so this passphrase needs to be viable for all identity files
	// that contain a passphrase. If needing multiple identity files be sure
	// they all use the same passphrase for the remote systems.
	SSHPassphrase string

	// SSHPASSFlags is for setting or overriding any sort of sshpass features.
	SSHPASSFlags []string
	// contains filtered or unexported fields
}

func (*Config) Arguments

func (c *Config) Arguments() []string

Arguments returns a string slice representation of all of the command line arguments required for the binary to work. If using sshpass parameters they will be placed at the start of the slice while all others float to the end. Think of these as the commands a user would normally manually type to use the binary.

func (*Config) Binary

func (c *Config) Binary() string

Binary returns the system path location for either the ssh binary (by default) or the sshpass binary depending on if the plugin configuration requires the use of sshpass or not.

func (*Config) Environment

func (c *Config) Environment() map[string]string

func (*Config) Setup

func (c *Config) Setup() error

Setup will make sure all of the internal configuration of the plugin is set and ready to go along with any sorts of file system side effects and preparations are done.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks some basic plugin configuration parameters to ensure everything is set that we need or expect and that and sort of conflicting parameters are sorted appropriately. Note that we're really not validating that the format of the parameters is correct since we'll just rely on surfacing those errors by using the binary itself. Why duplicate that validation logic when the binaries can do that for us?

Jump to

Keyboard shortcuts

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