mirror of
https://github.com/juanfont/headscale.git
synced 2026-02-07 20:04:00 +01:00
hsic: add ReadLog method for container log inspection
Add ReadLog() to HeadscaleInContainer and the ControlServer interface so integration tests can inspect container logs at runtime. This is needed by the SSH check mode tests to extract the auth-id from headscale log output. Updates #1850
This commit is contained in:
parent
d4e0e92ed1
commit
9f1cb6fdc5
@ -16,6 +16,7 @@ import (
|
||||
type ControlServer interface {
|
||||
Shutdown() (string, string, error)
|
||||
SaveLog(path string) (string, string, error)
|
||||
ReadLog() (string, string, error)
|
||||
SaveProfile(path string) error
|
||||
Execute(command []string) (string, error)
|
||||
WriteFile(path string, content []byte) error
|
||||
|
||||
@ -699,6 +699,18 @@ func (t *HeadscaleInContainer) WriteLogs(stdout, stderr io.Writer) error {
|
||||
return dockertestutil.WriteLog(t.pool, t.container, stdout, stderr)
|
||||
}
|
||||
|
||||
// ReadLog returns the current stdout and stderr logs from the headscale container.
|
||||
func (t *HeadscaleInContainer) ReadLog() (string, string, error) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
|
||||
err := dockertestutil.WriteLog(t.pool, t.container, &stdout, &stderr)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("reading container logs: %w", err)
|
||||
}
|
||||
|
||||
return stdout.String(), stderr.String(), nil
|
||||
}
|
||||
|
||||
// SaveLog saves the current stdout log of the container to a path
|
||||
// on the host system.
|
||||
func (t *HeadscaleInContainer) SaveLog(path string) (string, string, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user