sshhelper

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicPipeHandler

func BasicPipeHandler(r io.Reader, logout chan []byte, wg *sync.WaitGroup)

BasicPipeHandler is a simple implementation of the StreamingFunc function type. It does not transform the data coming in, it just writes it directly to the logout channel.

func CreateSSHDockerContainer

func CreateSSHDockerContainer(t *testing.T, forwardPort string) (cleanup func(), ctx context.Context)

Types

type Channel

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

func CreateSSHChannel

func CreateSSHChannel(ctx context.Context, facts *models.SSHFacts, hash string) (*Channel, error)

CreateSSHChannel will use the werker's configured ssh facts to create an SSH client. It will error at this point

if the client cannot connect to the remote sshd. It will also kick off the handleCtx method that will kill the active session and attempt to stop any associated processes

func (*Channel) AppendGlobals

func (c *Channel) AppendGlobals(envs []string)

func (*Channel) CheckConnection

func (c *Channel) CheckConnection() error

CheckConnection will create a session and attempt to run an echo command. Will return any errors; if error is

nil you can assume everything is a-ok for running commands.

func (*Channel) Close

func (c *Channel) Close() error

func (*Channel) JustRun

func (c *Channel) JustRun(cmd string, envs []string) error

func (*Channel) RunAndLog

func (c *Channel) RunAndLog(cmd string, envs []string, logout chan []byte, streamingFunc StreamingFunc) error

RunAndLog runs a given command remotely via the ContextConnection's ssh client. The stdout and stderr will be processed by the given StreamingFunc function and written to logout. the function will wait for the StreamingFunc function to close its done channel on both the stdout processing and the stderr processing.

func (*Channel) SetGlobals

func (c *Channel) SetGlobals(envs []string)

func (*Channel) Setenvs

func (c *Channel) Setenvs(extraEnvs ...string) error

Setenvs sets the globalEnvVars and any extra environment variables to be set on the ssh session

type StreamingFunc

type StreamingFunc func(r io.Reader, logout chan []byte, wg *sync.WaitGroup)

StreamingFunc is the function that will read off the Reader and transform it, then write it to the logout channel. call wg.Done(), it synchronizes the ssh command execution. See BasicPipeHandler for implementation

Jump to

Keyboard shortcuts

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