Documentation ¶
Index ¶
- Constants
- func CreateTempFileFromString(content string, filemode os.FileMode) (*os.File, fail.Error)
- func SCPErrorString(retcode int) string
- func SSHErrorString(retcode int) string
- type BashLibraryDefinition
- type SSHCommand
- func (scmd *SSHCommand) Close() fail.Error
- func (scmd *SSHCommand) CombinedOutput() ([]byte, fail.Error)
- func (scmd *SSHCommand) Kill() fail.Error
- func (scmd *SSHCommand) Output() ([]byte, fail.Error)
- func (scmd *SSHCommand) RunWithTimeout(ctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)
- func (scmd *SSHCommand) Start() fail.Error
- func (scmd *SSHCommand) Wait() error
- type SSHConfig
- func (sconf *SSHConfig) Clone() *SSHConfig
- func (sconf *SSHConfig) CopyWithTimeout(ctx context.Context, remotePath, localPath string, isUpload bool, ...) (int, string, string, fail.Error)
- func (sconf *SSHConfig) CreateTunneling() (_ SSHTunnels, _ *SSHConfig, ferr fail.Error)
- func (sconf *SSHConfig) Enter(username, shell string) (ferr fail.Error)
- func (sconf *SSHConfig) IsNull() bool
- func (sconf *SSHConfig) NewCommand(ctx context.Context, cmdString string) (*SSHCommand, fail.Error)
- func (sconf *SSHConfig) NewSudoCommand(ctx context.Context, cmdString string) (*SSHCommand, fail.Error)
- func (sconf *SSHConfig) WaitServerReady(ctx context.Context, phase string, timeout time.Duration) (out string, ferr fail.Error)
- type SSHTunnel
- type SSHTunnels
Constants ¶
const ( BashLibraryReservedKeyword = "reserved_BashLibrary" DefaultDelayReservedKeyword = "reserved_DefaultDelay" DefaultTimeoutReservedKeyword = "reserved_DefaultTimeout" LongTimeoutReservedKeyword = "reserved_LongTimeout" ClusterJoinTimeoutReservedKeyword = "reserved_ClusterJoinTimeout" DockerImagePullTimeoutReservedKeyword = "reserved_DockerImagePullTimeout" )
Variables ¶
This section is empty.
Functions ¶
func CreateTempFileFromString ¶
CreateTempFileFromString creates a temporary file containing 'content'
func SCPErrorString ¶
SCPErrorString returns if possible the string corresponding to SCP execution
func SSHErrorString ¶
SSHErrorString returns if possible the string corresponding to SSH execution
Types ¶
type BashLibraryDefinition ¶
type BashLibraryDefinition struct { Content string `json:"reserved_BashLibrary"` DefaultDelay uint `json:"reserved_DefaultDelay"` DefaultTimeout string `json:"reserved_DefaultTimeout"` LongTimeout string `json:"reserved_LongTimeout"` ClusterJoinTimeout string `json:"reserved_ClusterJoinTimeout"` DockerImagePullTimeout string `json:"reserved_DockerImagePullTimeout"` }
func BuildBashLibraryDefinition ¶
func BuildBashLibraryDefinition( timings temporal.Timings, ) (*BashLibraryDefinition, fail.Error)
BuildBashLibraryDefinition generates the content of {{.reserved_BashLibrary}} and other reserved template variables
type SSHCommand ¶
type SSHCommand struct {
// contains filtered or unexported fields
}
SSHCommand defines a SSH command
func (*SSHCommand) Close ¶
func (scmd *SSHCommand) Close() fail.Error
Close is called to clean SSHCommand (close tunnel(s), remove temporary files, ...)
func (*SSHCommand) CombinedOutput ¶
func (scmd *SSHCommand) CombinedOutput() ([]byte, fail.Error)
CombinedOutput returns the combined standard of command started output and standard error.
func (*SSHCommand) Output ¶
func (scmd *SSHCommand) Output() ([]byte, fail.Error)
Output returns the standard output of command started. Any returned error will usually be of type *ExitError. If c.Stderr was nil, Output populates ExitError.Stderr.
func (*SSHCommand) RunWithTimeout ¶
func (scmd *SSHCommand) RunWithTimeout(ctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)
RunWithTimeout ... returns:
- retcode int
- stdout string
- stderr string
- xerr fail.Error . *fail.ErrNotAvailable if remote SSH is not available . *fail.ErrTimeout if 'timeout' is reached
Note: if you want to RunWithTimeout in a loop, you MUST create the scmd inside the loop, otherwise
you risk to call twice os/exec.Wait, which may panic
FIXME: maybe we should move this method inside sshconfig directly with systematically created scmd...
func (*SSHCommand) Start ¶
func (scmd *SSHCommand) Start() fail.Error
Start starts the specified command but does not wait for it to complete. The Wait method will wait for completion and return the exit code.
func (*SSHCommand) Wait ¶
func (scmd *SSHCommand) Wait() error
Wait waits for the command to exit and waits for any copying to stdin or copying from stdout or stderr to complete. The command must have been started by Start. The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status. If the command fails to run or doesn't complete successfully, the error is of type *ExitError. Other error types may be returned for I/O problems. Wait also waits for the I/O loop copying from c.Stdin into the process's standard input to complete. Wait does not release resources associated with the cmd; SSHCommand.Close() must be called for that. !!!WARNING!!!: the error returned is NOT USING fail.Error because we may NEED TO CAST the error to recover return code
type SSHConfig ¶
type SSHConfig struct { Hostname string `json:"hostname"` IPAddress string `json:"ip_address"` Port int `json:"port"` User string `json:"user"` PrivateKey string `json:"private_key"` LocalPort int `json:"-"` GatewayConfig *SSHConfig `json:"primary_gateway_config,omitempty"` SecondaryGatewayConfig *SSHConfig `json:"secondary_gateway_config,omitempty"` }
SSHConfig helper to manage ssh session
func (*SSHConfig) CopyWithTimeout ¶
func (sconf *SSHConfig) CopyWithTimeout( ctx context.Context, remotePath, localPath string, isUpload bool, timeout time.Duration, ) (int, string, string, fail.Error)
CopyWithTimeout copies a file/directory from/to local to/from remote, and fails after 'timeout'
func (*SSHConfig) CreateTunneling ¶
func (sconf *SSHConfig) CreateTunneling() (_ SSHTunnels, _ *SSHConfig, ferr fail.Error)
CreateTunneling ...
func (*SSHConfig) NewCommand ¶
NewCommand returns the cmd struct to execute runCmdString remotely
func (*SSHConfig) NewSudoCommand ¶
func (sconf *SSHConfig) NewSudoCommand(ctx context.Context, cmdString string) (*SSHCommand, fail.Error)
NewSudoCommand returns the cmd struct to execute runCmdString remotely. NewCommand is executed with sudo
type SSHTunnel ¶
type SSHTunnel struct {
// contains filtered or unexported fields
}
SSHTunnel a SSH tunnel
type SSHTunnels ¶
type SSHTunnels []*SSHTunnel