Documentation ¶
Index ¶
- func Run(c Client, cmd string, args ...string) error
- func RunWithLogger(l *log.Logger, c Client, cmd string, args ...string) error
- type Client
- func NewLocalClient() Client
- func NewLoggedClient(l *log.Logger, c Client) Client
- func NewSSHClient(addr, user string, opts ...SSHOption) (Client, error)
- func NewSSHProxyClient(proxy Client, addr, user string, opts ...SSHOption) (Client, error)
- func NewWrappedClient(client Client, wrapper string) Client
- type SSHOption
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { // Create a new session for the given command. NewSession(cmd string, args ...string) (Session, error) // Dial to the given address and get a connection. Dial(n, addr string) (net.Conn, error) // Close the client and all respective sessions. Close() error }
Client will create provide the connection to the target and the session for commands to be executed.
func NewLocalClient ¶
func NewLocalClient() Client
NewLocalClient will execute commands on the local machine.
func NewLoggedClient ¶
NewLoggedClient will create a client, that will send all session output and error output to the given logger.
func NewSSHClient ¶
NewSSHClient will connect via SSH to the given address using the user specified.
func NewSSHProxyClient ¶
NewSSHProxyClient will create a connection through a proxy client, i.e. the given client will be used as a proxy to the target configured in this client.
func NewWrappedClient ¶
NewWrappedClient will use the given client and wrap all sessions with a command. This can be used to wrap commands in a `sudo` session for example.
type SSHOption ¶
type SSHOption func(*sshCfg) error
func SSHWithAgent ¶
func SSHWithAgent() SSHOption
func SSHWithAskPassword ¶
func SSHWithAskPassword() SSHOption
func SSHWithHostCheck ¶
func SSHWithHostCheckFile ¶
func SSHWithHostCheckFile() SSHOption
func SSHWithPort ¶
type Session ¶
type Session interface { // Close the session. Might return io.EOF if the session was already // closed. Especially with SSH that is expected behavior. Close() error // Get a handle to the standard input of the command session. StdinPipe() (io.WriteCloser, error) // Get a handle to the standard output of the command session. StdoutPipe() (io.Reader, error) // Get a handle to the standard error output of the command session. StderrPipe() (io.Reader, error) // Run the session. This will trigger both `Start` and `Wait`. Run() error // Start the session. Start() error // Wait for the session to finish. Wait() error }
Session provides the interface for a command execution session.