Documentation ¶
Index ¶
- Constants
- func Cmd(name string, arg ...string) error
- func CmdBatch(sshConfig *SSH, hosts []string, cmd string, walk Walk) error
- func CmdBatchWithSudo(sshConfig *SSH, hosts []string, cmd string, walk Walk) error
- func Combine(cmdList []string) string
- func DefaultWalk(result Result, err error) error
- func ExtraExitCode(err error) (bool, int)
- func GetRemoteHostName(sshConfig *SSH, hostIP string) (string, error)
- func IsFileExist(filepath string) (bool, error)
- func IsFloatIP(sshConfig *SSH, ip string) (bool, error)
- func MD5FromLocal(localPath string) (string, error)
- func NewSSHClient(username, password, ip string, port int) (*ssh.Client, error)
- func SSHToCmd(sshConfig *SSH, host string) bool
- func Whoami() string
- func WrapEcho(data, dest string) string
- func WrapSh(cmd string) string
- type LogicSSHWsSession
- type PtyHandler
- type Result
- type SSH
- func (ss *SSH) Copy(host, localFilePath, remoteFilePath string) error
- func (ss *SSH) CopyForMD5V2(host, localFilePath, remoteFilePath, localMD5 string) (bool, error)
- func (ss *SSH) CopySudo(host, localFilePath, remoteFilePath string) error
- func (ss *SSH) CopySudoWithBar(bar *mpb.Bar, host, localFilePath, remoteFilePath string) error
- func (ss *SSH) CopyWithBar(bar *mpb.Bar, host, localFilePath, remoteFilePath string) error
- func (ss *SSH) DownloadSudo(host, localFilePath, remoteFilePath string) error
- func (ss *SSH) IsFileExistV2(host, remoteFilePath string) (bool, error)
- func (ss *SSH) MD5FromRemote(host, remoteFilePath string) (string, error)
- func (ss *SSH) NewClient(host string) (*ssh.Client, error)
- func (ss *SSH) ValidateMd5sumLocalWithRemote(host, localFile, remoteFile string) (bool, error)
- type SSHConn
- type SSHRunCmd
- type TerminalSession
- type Terminaler
- type Walk
Constants ¶
const KB = 1024
const MB = 1024 * 1024
Variables ¶
This section is empty.
Functions ¶
func CmdBatchWithSudo ¶
CmdBatchWithSudo parallel run cmd with sudo on many hosts
func DefaultWalk ¶
func ExtraExitCode ¶ added in v1.1.1
func GetRemoteHostName ¶ added in v1.1.1
func IsFileExist ¶
func MD5FromLocal ¶
func SSHToCmd ¶ added in v1.1.1
SSHToCmd if caller don't provide enough config for run ssh cmd,change to run cmd by os.exec on localhost. for aio deploy now.
Types ¶
type LogicSSHWsSession ¶
type LogicSSHWsSession struct { IsFlagged bool // contains filtered or unexported fields }
func NewLoginSSHWSSession ¶
func (*LogicSSHWsSession) LogString ¶
func (sws *LogicSSHWsSession) LogString() string
func (*LogicSSHWsSession) Start ¶
func (sws *LogicSSHWsSession) Start(quitChan chan struct{})
func (*LogicSSHWsSession) Wait ¶
func (sws *LogicSSHWsSession) Wait(quitChan chan struct{}, gracefulExitChan chan struct{})
type PtyHandler ¶
type PtyHandler interface { io.Reader io.Writer remotecommand.TerminalSizeQueue }
PtyHandler is what remotecommand expects from a pty
type Result ¶
type Result struct { User string Host string Cmd string PrintCmd string Stdout string Stderr string ExitCode int }
func RunCmdAsSSH ¶ added in v1.1.1
func SSHCmd ¶
SSHCmd synchronously SSHs to a node running on provider and runs cmd. If there is no error performing the SSH, the stdout, stderr, and exit code are returned.
func SSHCmdWithSudo ¶
SSHCmdWithSudo try to run cmd with sudo.
func (Result) StdoutToString ¶
type SSH ¶
type SSH struct { User string `json:"user" yaml:"user,omitempty"` Password string `json:"password" yaml:"password,omitempty"` Port int `json:"port" yaml:"port,omitempty"` PkFile string `json:"pkFile" yaml:"pkFile,omitempty"` PrivateKey string `json:"privateKey" yaml:"privateKey,omitempty"` PkPassword string `json:"pkPassword" yaml:"pkPassword,omitempty"` ConnectionTimeout *time.Duration `json:"connectionTimeout,omitempty" yaml:"connectionTimeout,omitempty"` }
func (*SSH) CopyForMD5V2 ¶
CopyForMD5V2 copy and check md5
func (*SSH) CopySudoWithBar ¶ added in v1.2.0
func (*SSH) CopyWithBar ¶ added in v1.2.0
func (*SSH) DownloadSudo ¶
func (*SSH) MD5FromRemote ¶
type SSHConn ¶
type SSHConn struct { // calling Write() to write data into ssh server StdinPipe io.WriteCloser // Write() be called to receive data from ssh server ComboOutput *wsBufferWriter Session *ssh.Session }
connect to ssh server using ssh session.
func NewSSHConn ¶
setup ssh shell session set Session and StdinPipe here, and the Session.Stdout and Session.Sdterr are also set.
type TerminalSession ¶
type TerminalSession struct { Conn *websocket.Conn SizeChan chan remotecommand.TerminalSize }
TerminalSession implements PtyHandler (using a SockJS connection)
func (TerminalSession) Close ¶
func (t TerminalSession) Close(status uint32, reason string)
func (TerminalSession) Next ¶
func (t TerminalSession) Next() *remotecommand.TerminalSize
Next handles pty->process resize events Called in a loop from remotecommand as long as the process is running
func (TerminalSession) Read ¶
func (t TerminalSession) Read(p []byte) (int, error)
Read handles pty->process messages (stdin, resize) Called in a loop from remotecommand as long as the process is running
func (TerminalSession) Toast ¶
func (t TerminalSession) Toast(p string) error
type Terminaler ¶
type Terminaler struct {
// contains filtered or unexported fields
}
func NewTerminaler ¶
func NewTerminaler(client kubernetes.Interface, config *rest.Config) *Terminaler
func (*Terminaler) StartProcess ¶
func (t *Terminaler) StartProcess(namespace, podName, containerName string, cmd []string, ptyHandler PtyHandler) error