mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-11-04 10:01:05 +01:00 
			
		
		
		
	Add Execute helper for controlserver
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
		
							parent
							
								
									a647e6af24
								
							
						
					
					
						commit
						2c0488da0b
					
				@ -6,6 +6,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type ControlServer interface {
 | 
					type ControlServer interface {
 | 
				
			||||||
	Shutdown() error
 | 
						Shutdown() error
 | 
				
			||||||
 | 
						Execute(command []string) (string, error)
 | 
				
			||||||
	GetHealthEndpoint() string
 | 
						GetHealthEndpoint() string
 | 
				
			||||||
	GetEndpoint() string
 | 
						GetEndpoint() string
 | 
				
			||||||
	WaitForReady() error
 | 
						WaitForReady() error
 | 
				
			||||||
 | 
				
			|||||||
@ -103,6 +103,29 @@ func (t *HeadscaleInContainer) Shutdown() error {
 | 
				
			|||||||
	return t.pool.Purge(t.container)
 | 
						return t.pool.Purge(t.container)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (t *HeadscaleInContainer) Execute(
 | 
				
			||||||
 | 
						command []string,
 | 
				
			||||||
 | 
					) (string, error) {
 | 
				
			||||||
 | 
						log.Println("command", command)
 | 
				
			||||||
 | 
						log.Printf("running command for %s\n", t.hostname)
 | 
				
			||||||
 | 
						stdout, stderr, err := dockertestutil.ExecuteCommand(
 | 
				
			||||||
 | 
							t.container,
 | 
				
			||||||
 | 
							command,
 | 
				
			||||||
 | 
							[]string{},
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Printf("command stderr: %s\n", stderr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return "", err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if stdout != "" {
 | 
				
			||||||
 | 
							log.Printf("command stdout: %s\n", stdout)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return stdout, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (t *HeadscaleInContainer) GetIP() string {
 | 
					func (t *HeadscaleInContainer) GetIP() string {
 | 
				
			||||||
	return t.container.GetIPInNetwork(t.network)
 | 
						return t.container.GetIPInNetwork(t.network)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user