mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
[easyssh] make connect method as public. (appleboy/easyssh-proxy#36)
* make connect method as public. Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix go path. Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix golint error. Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> https://github.com/appleboy/drone-ssh/commit/ca8e8301291
This commit is contained in:
parent
71cbc0efd3
commit
cfa11e851a
18
vendor/github.com/appleboy/easyssh-proxy/easyssh.go
generated
vendored
18
vendor/github.com/appleboy/easyssh-proxy/easyssh.go
generated
vendored
@ -104,8 +104,8 @@ func getSSHConfig(config DefaultConfig) *ssh.ClientConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect to remote server using MakeConfig struct and returns *ssh.Session
|
// Connect to remote server using MakeConfig struct and returns *ssh.Session
|
||||||
func (ssh_conf *MakeConfig) connect() (*ssh.Session, error) {
|
func (ssh_conf *MakeConfig) Connect() (*ssh.Session, error) {
|
||||||
var client *ssh.Client
|
var client *ssh.Client
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -168,13 +168,13 @@ func (ssh_conf *MakeConfig) Stream(command string, timeout int) (<-chan string,
|
|||||||
doneChan := make(chan bool)
|
doneChan := make(chan bool)
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
|
|
||||||
// connect to remote host
|
// Connect to remote host
|
||||||
session, err := ssh_conf.connect()
|
session, err := ssh_conf.Connect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stdoutChan, stderrChan, doneChan, errChan, err
|
return stdoutChan, stderrChan, doneChan, errChan, err
|
||||||
}
|
}
|
||||||
// defer session.Close()
|
// defer session.Close()
|
||||||
// connect to both outputs (they are of type io.Reader)
|
// Connect to both outputs (they are of type io.Reader)
|
||||||
outReader, err := session.StdoutPipe()
|
outReader, err := session.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stdoutChan, stderrChan, doneChan, errChan, err
|
return stdoutChan, stderrChan, doneChan, errChan, err
|
||||||
@ -258,7 +258,7 @@ loop:
|
|||||||
|
|
||||||
// Scp uploads sourceFile to remote machine like native scp console app.
|
// Scp uploads sourceFile to remote machine like native scp console app.
|
||||||
func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error {
|
func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error {
|
||||||
session, err := ssh_conf.connect()
|
session, err := ssh_conf.Connect()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -297,9 +297,5 @@ func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := session.Run(fmt.Sprintf("scp -tr %s", etargetFile)); err != nil {
|
return session.Run(fmt.Sprintf("scp -tr %s", etargetFile))
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user