Skip to content

Commit

Permalink
Merge pull request #46 from Shopify/bodyclose-linter
Browse files Browse the repository at this point in the history
Bodyclose linter
  • Loading branch information
thepwagner authored Oct 20, 2021
2 parents 84ce205 + dfbe686 commit c6bc6e6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ linters:
- gofmt
- whitespace
- unparam
- bodyclose
fast: false


Expand Down
4 changes: 1 addition & 3 deletions v2/docker/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func GetDigestFromTagged(client *http.Client, image reference.NamedTagged) (dige
if err != nil {
return blank, err
}

defer resp.Body.Close()

if resp.StatusCode >= 300 {
Expand Down Expand Up @@ -63,13 +62,12 @@ func GetDigestFromCanonical(client *http.Client, image reference.Canonical) (dig
if err != nil {
return blank, err
}
defer resp.Body.Close()

if resp.StatusCode >= 300 {
return blank, responseToError(resp)
}

_ = resp.Body.Close()

imageDigest := digest.Digest(resp.Header.Get("Docker-Content-Digest"))
if "" == string(imageDigest) {
return blank, errors.New("empty digest returned for image")
Expand Down
1 change: 0 additions & 1 deletion v2/docker/schema2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func RequestConfig(client *http.Client, ref reference.Canonical, manifest distri
if nil != err {
return nil, err
}

defer resp.Body.Close()

if resp.StatusCode < 300 {
Expand Down
3 changes: 2 additions & 1 deletion v2/grafeas/grafeas_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ func (g *apiServiceImpl) httpCall(urlAddr *url.URL, payload []byte, method strin
}
return nil, err
}
defer resp.Body.Close()

statusCode := resp.StatusCode
data, err := ioutil.ReadAll(resp.Body)
if statusCode != http.StatusOK || err != nil {
return nil, NewAPIError(statusCode, urlAddr.Path, method, data)
}
resp.Body.Close()

return data, err
}

0 comments on commit c6bc6e6

Please sign in to comment.