Documentation ¶
Index ¶
- type CliCommand
- func (scmd *CliCommand) Close() (ferr fail.Error)
- func (scmd *CliCommand) CombinedOutput() ([]byte, fail.Error)
- func (scmd *CliCommand) Kill() fail.Error
- func (scmd *CliCommand) Output() ([]byte, fail.Error)
- func (scmd *CliCommand) RunWithTimeout(inctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)
- func (scmd *CliCommand) Start() fail.Error
- func (scmd *CliCommand) String() string
- func (scmd *CliCommand) Wait() error
- type Profile
- func (sconf *Profile) Clone() *Profile
- func (sconf *Profile) Config() (sshapi.Config, fail.Error)
- func (sconf *Profile) CopyWithTimeout(inctx context.Context, remotePath, localPath string, isUpload bool, ...) (int, string, string, fail.Error)
- func (sconf *Profile) CreatePersistentTunneling() (ferr fail.Error)
- func (sconf *Profile) CreateTunneling() (_ Tunnels, _ *Profile, ferr fail.Error)
- func (sconf *Profile) Enter(ctx context.Context, username string, shell string) (ferr fail.Error)
- func (sconf *Profile) GetGatewayConfig(num uint) (sshapi.Config, fail.Error)
- func (sconf *Profile) GetHostname() (string, fail.Error)
- func (sconf *Profile) GetIPAddress() (string, fail.Error)
- func (sconf *Profile) GetLocalHost() (string, fail.Error)
- func (sconf *Profile) GetLocalPort() (uint, fail.Error)
- func (sconf *Profile) GetPort() (uint, fail.Error)
- func (sconf *Profile) GetPrimaryGatewayConfig() (sshapi.Config, fail.Error)
- func (sconf *Profile) GetPrivateKey() (string, fail.Error)
- func (sconf *Profile) GetSecondaryGatewayConfig() (sshapi.Config, fail.Error)
- func (sconf *Profile) GetUser() (string, fail.Error)
- func (sconf *Profile) HasGateways() (bool, fail.Error)
- func (sconf *Profile) IsNull() bool
- func (sconf *Profile) NewCommand(ctx context.Context, cmdString string) (sshapi.Command, fail.Error)
- func (sconf *Profile) NewSudoCommand(ctx context.Context, cmdString string) (sshapi.Command, fail.Error)
- func (sconf *Profile) WaitServerReady(ctx context.Context, phase string, timeout time.Duration) (out string, ferr fail.Error)
- type Tunnel
- type Tunnels
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CliCommand ¶
type CliCommand struct {
// contains filtered or unexported fields
}
CliCommand defines a SSH command
func (*CliCommand) Close ¶
func (scmd *CliCommand) Close() (ferr fail.Error)
Close is called to clean Command (close tunnel(s), remove temporary files, ...)
func (*CliCommand) CombinedOutput ¶
func (scmd *CliCommand) CombinedOutput() ([]byte, fail.Error)
CombinedOutput returns the combined standard of command started output and standard error.
func (*CliCommand) Output ¶
func (scmd *CliCommand) 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 (*CliCommand) RunWithTimeout ¶
func (scmd *CliCommand) RunWithTimeout(inctx 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
func (*CliCommand) Start ¶
func (scmd *CliCommand) 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 (*CliCommand) String ¶
func (scmd *CliCommand) String() string
func (*CliCommand) Wait ¶
func (scmd *CliCommand) 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; Command.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 Profile ¶
type Profile 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:"-"` LocalHost string `json:"local_host"` GatewayConfig sshapi.Config `json:"primary_gateway_config,omitempty"` SecondaryGatewayConfig sshapi.Config `json:"secondary_gateway_config,omitempty"` }
Profile helper to manage ssh session
func NewProfile ¶
func (*Profile) CopyWithTimeout ¶
func (sconf *Profile) CopyWithTimeout( inctx 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 (*Profile) CreatePersistentTunneling ¶
func (*Profile) CreateTunneling ¶
CreateTunneling ...
func (*Profile) GetGatewayConfig ¶
func (*Profile) GetPrimaryGatewayConfig ¶
func (*Profile) GetSecondaryGatewayConfig ¶
func (*Profile) NewCommand ¶
func (sconf *Profile) NewCommand(ctx context.Context, cmdString string) (sshapi.Command, fail.Error)
NewCommand returns the cmd struct to execute runCmdString remotely