Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit a57b765

Browse files
committed
chore: fix bodyclose issues
Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 40e528c commit a57b765

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

query/base.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func ForBaseImageInIndex(digest digest.Digest, workspace string, apiKey string)
9999

100100
if resp.StatusCode == 200 {
101101
var manifestList []types.IndexManifestList
102+
defer resp.Body.Close() //nolint:errcheck
102103
body, err := io.ReadAll(resp.Body)
103104
if err != nil {
104105
return nil, errors.Wrapf(err, "failed to read response body")
@@ -141,6 +142,7 @@ func ForBaseImageWithoutCve(cve string, name string, sb *types.Sbom, workspace s
141142
}
142143

143144
var result ImageQueryResult
145+
defer resp.Body.Close() //nolint:errcheck
144146
err = edn.NewDecoder(resp.Body).Decode(&result)
145147
if err != nil {
146148
return nil, errors.Wrapf(err, "failed to unmarshal response")
@@ -182,6 +184,7 @@ func ForBaseImageInDb(digest digest.Digest, workspace string, apiKey string) (*[
182184
}
183185

184186
var result ImageQueryResult
187+
defer resp.Body.Close() //nolint:errcheck
185188
err = edn.NewDecoder(resp.Body).Decode(&result)
186189
if err != nil {
187190
return nil, errors.Wrapf(err, "failed to unmarshal response")
@@ -215,6 +218,7 @@ func ForRepositoryInDb(repo string, workspace string, apiKey string) (*types.Rep
215218
}
216219

217220
var result RepositoryQueryResult
221+
defer resp.Body.Close() //nolint:errcheck
218222
err = edn.NewDecoder(resp.Body).Decode(&result)
219223
if err != nil {
220224
return nil, errors.Wrapf(err, "failed to unmarshal response")

query/query.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func CheckAuth(workspace string, apiKey string) (bool, error) {
5656
if err != nil {
5757
return false, errors.Wrap(err, "failed to check auth")
5858
}
59+
defer resp.Body.Close() //nolint:errcheck
5960
if resp.StatusCode != 200 || err != nil {
6061
return false, nil
6162
}
@@ -81,6 +82,7 @@ func QueryCves(sb *types.Sbom, cve string, workspace string, apiKey string) (*[]
8182
return nil, errors.Wrapf(err, "failed to run query")
8283
}
8384
var result QueryResult
85+
defer resp.Body.Close() //nolint:errcheck
8486
err = edn.NewDecoder(resp.Body).Decode(&result)
8587
if err != nil {
8688
return nil, errors.Wrapf(err, "failed to unmarshal response")

0 commit comments

Comments
 (0)