Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit cf01b4d

Browse files
Merge pull request #9 from PatchMon/feature/websock
Fixed linting
2 parents bd2fd8d + 1a7d4b2 commit cf01b4d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

internal/integrations/docker/docker.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,24 @@ func (d *Integration) IsAvailable() bool {
6565
return false
6666
}
6767

68+
// Defer close to ensure cleanup if we don't store the client
69+
shouldClose := true
70+
defer func() {
71+
if shouldClose && cli != nil {
72+
_ = cli.Close()
73+
}
74+
}()
75+
6876
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
6977
defer cancel()
7078

7179
if _, err := cli.Ping(ctx); err != nil {
7280
d.logger.WithError(err).Debug("Failed to ping Docker daemon")
73-
cli.Close()
7481
return false
7582
}
7683

77-
// Store the client for later use
84+
// Store the client for later use (prevent deferred close)
85+
shouldClose = false
7886
d.client = cli
7987
return true
8088
}

0 commit comments

Comments
 (0)