ssh

package
v1.9.72 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func (Connection) Run

func (c Connection) Run(cmd string) (stdout, stderr []byte, exitCode int, err error)

func (Connection) Stream

func (c Connection) Stream(cmd string, stdoutWriter io.Writer) (stderr []byte, exitCode int, err error)

func (Connection) StreamStdin

func (c Connection) StreamStdin(cmd string, stdinReader io.Reader) (stdout, stderr []byte, exitCode int, err error)

func (Connection) Username

func (c Connection) Username() string

type Logger

type Logger interface {
	Warn(tag, msg string, args ...interface{})
	Debug(tag, msg string, args ...interface{})
	Error(tag, msg string, args ...interface{})
}

type RemoteRunner

type RemoteRunner interface {
	ConnectedUsername() string
	DirectoryExists(dir string) (bool, error)
	RemoveDirectory(dir string) error
	ArchiveAndDownload(directory string, writer io.Writer) error
	CreateDirectory(directory string) error
	ExtractAndUpload(reader io.Reader, directory string) error
	SizeOf(path string) (string, error)
	SizeInBytes(path string) (int, error)
	ChecksumDirectory(path string) (map[string]string, error)
	RunScript(path, label string) error
	RunScriptWithEnv(path string, env map[string]string, label string, stdout io.Writer) error
	FindFiles(pattern string) ([]string, error)
	IsWindows() (bool, error)
}

func NewSshRemoteRunner

func NewSshRemoteRunner(host, user, privateKey string, publicKeyCallback ssh.HostKeyCallback, publicKeyAlgorithm []string, logger Logger) (RemoteRunner, error)

type RemoteRunnerFactory

type RemoteRunnerFactory func(host, user, privateKey string, publicKeyCallback ssh.HostKeyCallback, publicKeyAlgorithm []string, logger Logger) (RemoteRunner, error)

type SSHConnection

type SSHConnection interface {
	Stream(cmd string, writer io.Writer) ([]byte, int, error)
	StreamStdin(cmd string, reader io.Reader) ([]byte, []byte, int, error)
	Run(cmd string) ([]byte, []byte, int, error)
	Username() string
}

func NewConnection

func NewConnection(hostName, userName, privateKey string, publicKeyCallback ssh.HostKeyCallback, publicKeyAlgorithm []string, logger Logger) (SSHConnection, error)

func NewConnectionWithServerAliveInterval

func NewConnectionWithServerAliveInterval(hostName, userName, privateKey string, publicKeyCallback ssh.HostKeyCallback, publicKeyAlgorithm []string, serverAliveInterval time.Duration, logger Logger) (SSHConnection, error)

type SSHOptsGenerator

type SSHOptsGenerator func(uuidGen uuid.Generator) (director.SSHOpts, string, error)

type SSHSession added in v1.9.1

type SSHSession interface {
	Run(cmd string) error
	SendRequest(name string, wantReply bool, payload []byte) (bool, error)
	Close() error
}

type SSHSessionBuilder added in v1.9.1

type SSHSessionBuilder = func(client *ssh.Client, stdin io.Reader, stdout, stderr io.Writer) (SSHSession, error)

type SshRemoteRunner

type SshRemoteRunner struct {
	// contains filtered or unexported fields
}

func (SshRemoteRunner) ArchiveAndDownload

func (r SshRemoteRunner) ArchiveAndDownload(directory string, writer io.Writer) error

func (SshRemoteRunner) ChecksumDirectory

func (r SshRemoteRunner) ChecksumDirectory(path string) (map[string]string, error)

func (SshRemoteRunner) ConnectedUsername

func (r SshRemoteRunner) ConnectedUsername() string

func (SshRemoteRunner) CreateDirectory

func (r SshRemoteRunner) CreateDirectory(directory string) error

func (SshRemoteRunner) DirectoryExists

func (r SshRemoteRunner) DirectoryExists(dir string) (bool, error)

func (SshRemoteRunner) ExtractAndUpload

func (r SshRemoteRunner) ExtractAndUpload(reader io.Reader, directory string) error

func (SshRemoteRunner) FindFiles

func (r SshRemoteRunner) FindFiles(pattern string) ([]string, error)

func (SshRemoteRunner) IsWindows

func (r SshRemoteRunner) IsWindows() (bool, error)

func (SshRemoteRunner) RemoveDirectory

func (r SshRemoteRunner) RemoveDirectory(dir string) error

func (SshRemoteRunner) RunScript

func (r SshRemoteRunner) RunScript(path, label string) error

func (SshRemoteRunner) RunScriptWithEnv

func (r SshRemoteRunner) RunScriptWithEnv(path string, env map[string]string, label string, stdout io.Writer) error

RunScriptWithEnv runs the script at 'path' on our remote environment. The script is run with the environment variables specified in 'env'. All logging is annotated with 'label'.

Instead of returning the contents of stdout as a string, we stream it to the Writer 'stdout' during the call. This means that if a given script outputs very large amounts of data to stdout, we don't cache it all in memory and run the risk of crashing the CLI.

func (SshRemoteRunner) SizeInBytes added in v1.7.2

func (r SshRemoteRunner) SizeInBytes(path string) (int, error)

func (SshRemoteRunner) SizeOf

func (r SshRemoteRunner) SizeOf(path string) (string, error)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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