Documentation ¶
Index ¶
- func IsPortOpen(portChecker func(port int) Result, port int) resource.StateRefreshFunc
- func IsServiceRunning(serviceChecker func(serviceName string) Result, serviceName string) resource.StateRefreshFunc
- func LogBufferContents(buffer *bytes.Buffer)
- func NewOpenPortCheckerFunc(client *Client) func(port int) Result
- func NewServiceStatusChecker(client *Client) func(serviceName string) Result
- func PanicOnError(r Result)
- func WaitForOpenPort(portChecker func(port int) Result, port int) error
- func WaitForService(serviceChecker func(serviceName string) Result, serviceName string) error
- func WithHostKey(hostKey string) func(params *Connection) error
- func WithHostParams(user string, host string, port int) func(params *Connection) error
- func WithPrivateKey(privateKey string) func(params *Connection) error
- type Agent
- type Bastion
- type Client
- type Connection
- type OutputBuffer
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPortOpen ¶
func IsPortOpen(portChecker func(port int) Result, port int) resource.StateRefreshFunc
IsPortOpen returns a StateRefreshFunc for determining if the specified port is open
func IsServiceRunning ¶
func IsServiceRunning(serviceChecker func(serviceName string) Result, serviceName string) resource.StateRefreshFunc
IsServiceRunning returns a StateRefreshFunc for determining if the specified service is running
func LogBufferContents ¶
LogBufferContents waits for data to be sent to the buffer and logs each line until the buffer can't be read from anymore if a copyBuffer is passed (not nil) the output will also be copied to it
func NewOpenPortCheckerFunc ¶
NewOpenPortCheckerFunc constructs a function based on the specified ssh.Client, which checks if the specified port is open
func NewServiceStatusChecker ¶
NewServiceStatusChecker constructs a function based on the specified ssh.Client, which checks if the specified service is running
func PanicOnError ¶
func PanicOnError(r Result)
PanicOnError panic if a result has completed with an error (useful in situations where errors are not recoverable, but we want to allow error handling at an upper layer
func WaitForOpenPort ¶
WaitForOpenPort returns when the specified port is open, or with an error if the operation times out
func WaitForService ¶
WaitForService returns when the specified service is found to be running, or with an error if the operation times out
func WithHostKey ¶
func WithHostKey(hostKey string) func(params *Connection) error
WithHostKey specifies the host keys of the target host
func WithHostParams ¶
func WithHostParams(user string, host string, port int) func(params *Connection) error
WithHostParams accepts the minimal set of parameters required to make a connection
func WithPrivateKey ¶
func WithPrivateKey(privateKey string) func(params *Connection) error
WithPrivateKey specifies the private keys to use for connecting to the target host
Types ¶
type Agent ¶
type Agent struct { Agent bool `json:"agent,string,omitempty"` AgentIdentity string `json:"agent_identity,omitempty"` }
Agent holds SSH agent configuration parameters
type Bastion ¶
type Bastion struct { BastionUser string `json:"bastion_user,omitempty"` BastionPassword string `json:"bastion_password,omitempty"` BastionPrivateKey string `json:"bastion_private_key,omitempty"` BastionHost string `json:"bastion_host,omitempty"` BastionHostKey string `json:"bastion_host_key,omitempty"` BastionPort int `json:"bastion_port,string,omitempty"` }
Bastion holds all parameters required to make an SSH connection through a bastion host
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client abstracts all usage of SSH primitives into a nice, easy-to-use API
func NewClient ¶
func NewClient(params ...func(*Connection) error) (*Client, error)
NewClient creates a new SSH client
func (*Client) RunCommand ¶
RunCommand executes a command on the remote host and returns the command's output, the SSH communicator's output and an error
func (*Client) UploadData ¶
UploadData uploads all contents from the specified io.Reader to the remote path
type Connection ¶
type Connection struct { User string `json:"user,omitempty"` Password string `json:"password,omitempty"` PrivateKey string `json:"private_key,omitempty"` Host string `json:"host,omitempty"` HostKey string `json:"host_key,omitempty"` Port int `json:"port,string,omitempty"` Bastion Agent }
Connection holds all connection parameters used to connect to a host via SSH
type OutputBuffer ¶
type OutputBuffer struct {
// contains filtered or unexported fields
}
OutputBuffer used to send SSH command output to log.Printf
func (*OutputBuffer) Output ¶
func (o *OutputBuffer) Output(line string)
Output writes the passed line into a byte buffer for later consumption; respects the terraform.UIOutput interface