Documentation ¶
Index ¶
- func BackupFile(s Interface, file string) (string, error)
- func DiskAvail(s Interface, path string) (int, error)
- func FormatFileSize(s int64) (size string)
- func GetNetworkInterface(s Interface, ip string) string
- func MakePrivateKeySigner(privateKey []byte, passPhrase []byte) (ssh.Signer, error)
- func MakePrivateKeySignerFromFile(key string) (ssh.Signer, error)
- func MemoryCapacity(s Interface) (uint64, error)
- func NewSftpClient(user, password, host string, port int, timeoutSec time.Duration) (*sftp.Client, error)
- func NumCPU(s Interface) (int, error)
- func ParsePublicKeyFromFile(keyFile string) (*rsa.PublicKey, error)
- func RestoreFile(s Interface, file string) error
- func Timestamp(s Interface) (int, error)
- func UploadLocalFileBySftp(objClient *sftp.Client, srcFilePath, remotePath string) error
- type Config
- type Interface
- type ProxyConfig
- type SSH
- func (s *SSH) CombinedOutput(cmd string) ([]byte, error)
- func (s *SSH) CopyDir(src, dst string) error
- func (s *SSH) CopyFile(src, dst string) error
- func (s *SSH) Exec(cmd string) (stdout string, stderr string, exit int, err error)
- func (s *SSH) Execf(format string, a ...interface{}) (stdout string, stderr string, exit int, err error)
- func (s *SSH) Exist(filename string) (bool, error)
- func (s *SSH) LookPath(file string) (string, error)
- func (s *SSH) Ping() error
- func (s *SSH) ReadFile(filename string) ([]byte, error)
- func (s *SSH) WriteFile(src io.Reader, dst string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNetworkInterface ¶
GetNetworkInterface return network interface name by ip
func MakePrivateKeySigner ¶
func MemoryCapacity ¶
MemoryCapacity returns the machine's total memory from /proc/meminfo. Returns the total memory capacity as an uint64 (number of bytes).
func NewSftpClient ¶
func NewSftpClient(user, password, host string, port int, timeoutSec time.Duration) (*sftp.Client, error)
create new sftp client
func RestoreFile ¶
Types ¶
type Config ¶
type Config struct { User string `validate:"required"` Host string `validate:"required"` Port int `validate:"required"` Sudo bool Password string PrivateKey []byte PassPhrase []byte // 150 seconds is longer than the underlying default TCP backoff delay (127 // seconds). This timeout is only intended to catch otherwise uncaught hangs. DialTimeOut time.Duration ReadTimeOut time.Duration Retry int Proxy *ProxyConfig }
type Interface ¶
type Interface interface { Ping() error CombinedOutput(cmd string) ([]byte, error) Execf(format string, a ...interface{}) (stdout string, stderr string, exit int, err error) Exec(cmd string) (stdout string, stderr string, exit int, err error) CopyFile(src, dst string) error WriteFile(src io.Reader, dst string) error ReadFile(filename string) ([]byte, error) Exist(filename string) (bool, error) LookPath(file string) (string, error) }
Click to show internal directories.
Click to hide internal directories.