machine

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//IsTesting only set it in test package
	IsTesting = false
)

Functions

This section is empty.

Types

type ExecClient

type ExecClient struct {
	SSHClient  *ssh.Client
	SFTPClient *sftp.Client
}

func NewExecClient

func NewExecClient(node *pb.Node) (*ExecClient, error)

NewExecClient create a new execution client

func (*ExecClient) Close

func (m *ExecClient) Close()

Close will only close ssh client no need to close sftp client since it's based on ssh client

func (*ExecClient) ReadFile

func (m *ExecClient) ReadFile(filename string) (content []byte, err error)

ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported. Like ioutil.ReadFile

func (*ExecClient) WriteFile

func (m *ExecClient) WriteFile(filename string, data []byte, perm os.FileMode) (err error)

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm; otherwise WriteFile truncates it before writing. Like ioutil.WriteFile

type IMachine

type IMachine interface {
	GetName() string
	GetIp() string
	GetNode() *pb.Node
	Close()

	Run(cmd string) (stdout, stderr []byte, err error)
	FetchDir(localDir, remoteDir string, fileNeeded func(path string) bool) error
	FetchFile(dst io.Writer, remotePath string) error
	FetchFileToLocalPath(localPath, remotePath string) error
	PutDir(localDir, remoteDir string, fileNeeded func(path string) bool) error
	PutFile(content io.Reader, remotePath string) error
}

func NewMachine

func NewMachine(node *pb.Node) (IMachine, error)

type Machine

type Machine struct {
	*ExecClient
	*pb.Node
}

func (*Machine) Close

func (m *Machine) Close()

func (*Machine) FetchDir

func (m *Machine) FetchDir(localDir, remoteDir string, fileNeeded func(path string) bool) error

func (*Machine) FetchFile

func (m *Machine) FetchFile(dst io.Writer, remotePath string) error

func (*Machine) FetchFileToLocalPath

func (m *Machine) FetchFileToLocalPath(localPath, remotePath string) error

func (*Machine) GetIp

func (m *Machine) GetIp() string

func (*Machine) GetName

func (m *Machine) GetName() string

func (*Machine) GetNode

func (m *Machine) GetNode() *pb.Node

func (*Machine) PutDir

func (m *Machine) PutDir(localDir, remoteDir string, fileNeeded func(path string) bool) error

func (*Machine) PutFile

func (m *Machine) PutFile(content io.Reader, remotePath string) error

func (*Machine) Run

func (m *Machine) Run(cmd string) (stdout, stderr []byte, err error)

Run will run command on remote machine

type MockMachine

type MockMachine struct {
	*pb.Node
	DockerClient *dockerclient.Client
}

func (*MockMachine) Close

func (m *MockMachine) Close()

func (*MockMachine) FetchDir

func (m *MockMachine) FetchDir(localDir, remoteDir string, fileNeeded func(path string) bool) error

func (*MockMachine) FetchFile

func (m *MockMachine) FetchFile(dst io.Writer, remotePath string) error

func (*MockMachine) FetchFileToLocalPath

func (m *MockMachine) FetchFileToLocalPath(localPath, remotePath string) error

func (*MockMachine) GetIp

func (m *MockMachine) GetIp() string

func (*MockMachine) GetName

func (m *MockMachine) GetName() string

func (*MockMachine) GetNode

func (m *MockMachine) GetNode() *pb.Node

func (*MockMachine) PutDir

func (m *MockMachine) PutDir(localDir, remoteDir string, fileNeeded func(path string) bool) error

func (*MockMachine) PutFile

func (m *MockMachine) PutFile(content io.Reader, remotePath string) error

func (*MockMachine) Run

func (m *MockMachine) Run(cmd string) (stdout, stderr []byte, err error)

Run return different response by node name

func (*MockMachine) StartDockerTunnel

func (m *MockMachine) StartDockerTunnel() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL