Documentation ¶
Index ¶
- func CopyDir(sshClient Interface, host, src, dest string, filter func(fs.DirEntry) bool) error
- func GetTimeoutContext() (context.Context, context.CancelFunc)
- func NewSudoSftpClient(conn *ssh.Client, sudopwd string, opts ...sftp.ClientOption) (*sftp.Client, error)
- func OverSSHConfig(original, override *v1beta1.SSH)
- func RegisterFlags(fs *pflag.FlagSet)
- func WaitReady(client Interface, _ int, hosts ...string) error
- type Client
- func (c *Client) Cmd(host, cmd string) ([]byte, error)
- func (c *Client) CmdAsync(host string, cmds ...string) error
- func (c *Client) CmdAsyncWithContext(ctx context.Context, host string, cmds ...string) error
- func (c *Client) CmdToString(host, cmd, sep string) (string, error)
- func (c *Client) Connect(host string) (sshClient *ssh.Client, session *ssh.Session, err error)
- func (c *Client) Copy(host, localPath, remotePath string) error
- func (c *Client) Fetch(host, src, dst string) error
- func (c *Client) Ping(host string) error
- func (c *Client) RemoteSha256Sum(host, remoteFilePath string) string
- type HostClient
- type HostClientMap
- type Interface
- type Option
- type OptionFunc
- func WithHostKeyCallback(fn ssh.HostKeyCallback) OptionFunc
- func WithPassword(p string) OptionFunc
- func WithPrivateKeyAndPhrase(pk, passphrase string) OptionFunc
- func WithRawPrivateKeyDataAndPhrase(raw, passphrase string) OptionFunc
- func WithStdoutEnable(b bool) OptionFunc
- func WithSudoEnable(b bool) OptionFunc
- func WithTimeout(timeout time.Duration) OptionFunc
- func WithUsername(u string) OptionFunc
- type Remote
- func (s *Remote) CGroup(ip string) (string, error)
- func (s *Remote) Cert(ip string, altNames []string, nodeIP, nodeName, serviceCIRD, DNSDomain string) error
- func (s *Remote) Hostname(ip string) (string, error)
- func (s *Remote) HostsAdd(ip, host, domain string) error
- func (s *Remote) HostsDelete(ip, domain string) error
- func (s *Remote) IPVS(ip, vip string, masters []string) error
- func (s *Remote) IPVSClean(ip, vip string) error
- func (s *Remote) InitSystem(ip string) initsystem.InitSystem
- func (s *Remote) Socket(ip string) (string, error)
- func (s *Remote) StaticPod(ip, vip, name, image string, masters []string, path string, options ...string) error
- func (s *Remote) Token(ip, config, certificateKey string) (string, error)
- type RenderTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTimeoutContext ¶
func GetTimeoutContext() (context.Context, context.CancelFunc)
GetTimeoutContext create a context.Context with default timeout default execution timeout in sealos is just fine, if you want to customize the timeout setting, you must invoke the `RegisterFlags` function above.
func NewSudoSftpClient ¶
func OverSSHConfig ¶
func RegisterFlags ¶
Types ¶
type Client ¶
type Client struct { *ssh.ClientConfig *Option }
func (*Client) CmdAsyncWithContext ¶
func (*Client) CmdToString ¶
CmdToString execute command on host and replace output with sep to oneline
func (*Client) RemoteSha256Sum ¶
type HostClientMap ¶
type HostClientMap struct { ClientMap map[string]HostClient Mux sync.Mutex }
type Interface ¶
type Interface interface { // Copy copy local file to remote // scp -r /tmp root@192.168.0.2:/root/tmp => Copy("192.168.0.2","tmp","/root/tmp") // skip checksum if env DO_NOT_CHECKSUM=true Copy(host, src, dst string) error // Fetch fetch remote file to local // scp -r root@192.168.0.2:/remote/path/file /local/path/file => Fetch("192.168.0.2","/remote/path/file", "/local/path/file",) Fetch(host, src, dst string) error // CmdAsync exec commands on remote host asynchronously CmdAsync(host string, cmds ...string) error CmdAsyncWithContext(ctx context.Context, host string, cmds ...string) error // Cmd exec command on remote host, and return combined standard output and standard error Cmd(host, cmd string) ([]byte, error) // CmdToString exec command on remote host, and return spilt standard output by separator and standard error CmdToString(host, cmd, spilt string) (string, error) Ping(host string) error }
type OptionFunc ¶
type OptionFunc func(*Option)
func WithHostKeyCallback ¶
func WithHostKeyCallback(fn ssh.HostKeyCallback) OptionFunc
func WithPassword ¶
func WithPassword(p string) OptionFunc
func WithPrivateKeyAndPhrase ¶
func WithPrivateKeyAndPhrase(pk, passphrase string) OptionFunc
func WithRawPrivateKeyDataAndPhrase ¶
func WithRawPrivateKeyDataAndPhrase(raw, passphrase string) OptionFunc
func WithStdoutEnable ¶
func WithStdoutEnable(b bool) OptionFunc
func WithSudoEnable ¶
func WithSudoEnable(b bool) OptionFunc
func WithTimeout ¶
func WithTimeout(timeout time.Duration) OptionFunc
func WithUsername ¶
func WithUsername(u string) OptionFunc
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
func NewRemoteFromSSH ¶
func (*Remote) HostsDelete ¶
func (*Remote) InitSystem ¶
func (s *Remote) InitSystem(ip string) initsystem.InitSystem
Click to show internal directories.
Click to hide internal directories.