Documentation
¶
Index ¶
- func Connect(cfg ConnectConfig) (*ssh.Client, error)
- func ResolveKeyPath(keyName string) string
- func RunCommand(client *ssh.Client, command string, stdout, stderr io.Writer) (int, error)
- func RunScript(client *ssh.Client, script []byte, env map[string]string, ...) (int, error)
- func RunWithStdin(client *ssh.Client, command string, stdinData io.Reader, ...) (int, error)
- func ServerIP(s *model.Server) (string, error)
- func ValidateAppName(name string) error
- func ValidateEnvKey(key string) error
- type ConnectConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(cfg ConnectConfig) (*ssh.Client, error)
Connect establishes an SSH connection.
func ResolveKeyPath ¶
ResolveKeyPath returns the SSH private key path for a server's key name. Looks for ~/.ssh/conoha_<keyName>. Returns empty string if not found.
func RunCommand ¶
RunCommand executes a single command on the remote server. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.
func RunScript ¶
func RunScript(client *ssh.Client, script []byte, env map[string]string, stdout, stderr io.Writer) (int, error)
RunScript uploads and executes a script on the remote server. Environment variables are exported before the script runs. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.
NOTE: env keys must be validated with ValidateEnvKey before calling.
func RunWithStdin ¶
func RunWithStdin(client *ssh.Client, command string, stdinData io.Reader, stdout, stderr io.Writer) (int, error)
RunWithStdin executes a command, piping stdinData to its stdin. Stdout/stderr are streamed to the provided writers. Returns the remote exit code.
func ServerIP ¶
ServerIP extracts the best IPv4 address from server addresses. Prefers floating IPv4 over fixed IPv4, falls back to any IPv4.