Skip to content

Commit

Permalink
Add Execute helper for controlserver
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed Oct 26, 2022
1 parent a647e6a commit 2c0488d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

type ControlServer interface {
Shutdown() error
Execute(command []string) (string, error)
GetHealthEndpoint() string
GetEndpoint() string
WaitForReady() error
Expand Down
23 changes: 23 additions & 0 deletions integration/hsic/hsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ func (t *HeadscaleInContainer) Shutdown() error {
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 {
return t.container.GetIPInNetwork(t.network)
}
Expand Down

0 comments on commit 2c0488d

Please sign in to comment.