mirror of
				https://github.com/appleboy/drone-ssh.git
				synced 2025-10-29 00:51:15 +08:00 
			
		
		
		
	refactor
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
		
							parent
							
								
									5f511f0399
								
							
						
					
					
						commit
						5af042b309
					
				
							
								
								
									
										11
									
								
								plugin.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								plugin.go
									
									
									
									
									
								
							| @ -40,7 +40,7 @@ type ( | ||||
| ) | ||||
| 
 | ||||
| func (p Plugin) log(host string, message ...interface{}) { | ||||
| 	if len(host) == 0 { | ||||
| 	if count := len(p.Config.Host); count == 1 { | ||||
| 		fmt.Printf("%s", fmt.Sprintln(message...)) | ||||
| 	} else { | ||||
| 		fmt.Printf("%s: %s", host, fmt.Sprintln(message...)) | ||||
| @ -65,9 +65,8 @@ 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, counts int) { | ||||
| 		go func(host string) { | ||||
| 			// Create MakeConfig instance with remote username, server address and path to private key.
 | ||||
| 			ssh := &easyssh.MakeConfig{ | ||||
| 				Server:   host, | ||||
| @ -96,10 +95,6 @@ func (p Plugin) Exec() error { | ||||
| 				// read from the output channel until the done signal is passed
 | ||||
| 				stillGoing := true | ||||
| 				isTimeout := true | ||||
| 				// hide host in log if only single host in config.
 | ||||
| 				if counts == 1 { | ||||
| 					host = "" | ||||
| 				} | ||||
| 				for stillGoing { | ||||
| 					select { | ||||
| 					case isTimeout = <-doneChan: | ||||
| @ -124,7 +119,7 @@ func (p Plugin) Exec() error { | ||||
| 			} | ||||
| 
 | ||||
| 			wg.Done() | ||||
| 		}(host, countHosts) | ||||
| 		}(host) | ||||
| 	} | ||||
| 
 | ||||
| 	go func() { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Bo-Yi Wu
						Bo-Yi Wu