mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-07-02 21:52:51 +08:00
hide domain if only single host in config.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
efdac217bd
commit
b4613ae4db
14
plugin.go
14
plugin.go
@ -40,7 +40,11 @@ type (
|
||||
)
|
||||
|
||||
func (p Plugin) log(host string, message ...interface{}) {
|
||||
fmt.Printf("%s: %s", host, fmt.Sprintln(message...))
|
||||
if len(host) == 0 {
|
||||
fmt.Printf("%s", fmt.Sprintln(message...))
|
||||
} else {
|
||||
fmt.Printf("%s: %s", host, fmt.Sprintln(message...))
|
||||
}
|
||||
}
|
||||
|
||||
// Exec executes the plugin.
|
||||
@ -61,8 +65,12 @@ func (p Plugin) Exec() error {
|
||||
wg.Add(len(p.Config.Host))
|
||||
errChannel := make(chan error, 1)
|
||||
finished := make(chan bool, 1)
|
||||
countHosts := len(p.Config.Host)
|
||||
for _, host := range p.Config.Host {
|
||||
go func(host string) {
|
||||
go func(host string, counts int) {
|
||||
if counts == 1 {
|
||||
host = ""
|
||||
}
|
||||
// Create MakeConfig instance with remote username, server address and path to private key.
|
||||
ssh := &easyssh.MakeConfig{
|
||||
Server: host,
|
||||
@ -115,7 +123,7 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
|
||||
wg.Done()
|
||||
}(host)
|
||||
}(host, countHosts)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
Loading…
Reference in New Issue
Block a user