From b4613ae4db76524a33fd5c51ebb218d12e1b84bf Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 10 May 2017 21:05:16 +0800 Subject: [PATCH] hide domain if only single host in config. Signed-off-by: Bo-Yi Wu --- plugin.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin.go b/plugin.go index 90261ce..abe5c42 100644 --- a/plugin.go +++ b/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() {