From 28a40c001903a1e6c2b5b537e41d846d69df141f Mon Sep 17 00:00:00 2001 From: ArcticLampyrid Date: Fri, 15 Nov 2024 02:57:01 +0800 Subject: [PATCH] chore: cleanup --- hscontrol/handlers.go | 1 + integration/dsic/dsic.go | 4 +++- integration/tsic/tsic.go | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hscontrol/handlers.go b/hscontrol/handlers.go index 7a44aa27..00663ff6 100644 --- a/hscontrol/handlers.go +++ b/hscontrol/handlers.go @@ -64,6 +64,7 @@ func (h *Headscale) VerifyHandler( ) { if req.Method != http.MethodPost { http.Error(writer, "Wrong method", http.StatusMethodNotAllowed) + return } log.Debug(). diff --git a/integration/dsic/dsic.go b/integration/dsic/dsic.go index 4c948c48..f8bb85a9 100644 --- a/integration/dsic/dsic.go +++ b/integration/dsic/dsic.go @@ -72,7 +72,7 @@ func WithOrCreateNetwork(network *dockertest.Network) Option { network, err := dockertestutil.GetFirstOrCreateNetwork( tsic.pool, - fmt.Sprintf("%s-network", tsic.hostname), + tsic.hostname+"-network", ) if err != nil { log.Fatalf("failed to create network: %s", err) @@ -226,6 +226,7 @@ func New( return nil, fmt.Errorf("failed to write TLS key to container: %w", err) } } + return dsic, nil } @@ -239,6 +240,7 @@ func (t *DERPServerInContainer) Shutdown() error { fmt.Errorf("failed to save log: %w", err), ) } + return t.pool.Purge(t.container) } diff --git a/integration/tsic/tsic.go b/integration/tsic/tsic.go index 5035d1ca..de95b272 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -675,7 +675,7 @@ func (t *TailscaleInContainer) watchIPN(ctx context.Context) (*ipn.Notify, error func (t *TailscaleInContainer) DebugDERPRegion(region string) (*ipnstate.DebugDERPRegionReport, error) { if !util.TailscaleVersionNewerOrEqual("1.34", t.version) { - panic(fmt.Sprintf("tsic.DebugDERPRegion() called with unsupported version: %s", t.version)) + panic("tsic.DebugDERPRegion() called with unsupported version: " + t.version) } command := []string{ @@ -687,17 +687,18 @@ func (t *TailscaleInContainer) DebugDERPRegion(region string) (*ipnstate.DebugDE result, stderr, err := t.Execute(command) if err != nil { - fmt.Printf("stderr: %s\n", stderr) + fmt.Printf("stderr: %s\n", stderr) // nolint + return nil, fmt.Errorf("failed to execute tailscale debug derp command: %w", err) } - var st ipnstate.DebugDERPRegionReport - err = json.Unmarshal([]byte(result), &st) + var report ipnstate.DebugDERPRegionReport + err = json.Unmarshal([]byte(result), &report) if err != nil { return nil, fmt.Errorf("failed to unmarshal tailscale derp region report: %w", err) } - return &st, err + return &report, err } // Netcheck returns the current Netcheck Report (netcheck.Report) of the Tailscale instance.