fix defer on nil object
This commit is contained in:
parent
8bd785d8c1
commit
fa27815901
@ -47,11 +47,10 @@ func analyzeLayer(id string) (v1.LayerEnvelope, error) {
|
||||
|
||||
lURI := fmt.Sprintf("%v/layers/%v?vulnerabilities", uri, id)
|
||||
response, err := http.Get(lURI)
|
||||
defer response.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
return v1.LayerEnvelope{}, fmt.Errorf("analysing layer %v: %v", id, err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
var analysis v1.LayerEnvelope
|
||||
err = json.NewDecoder(response.Body).Decode(&analysis)
|
||||
|
@ -10,12 +10,11 @@ import (
|
||||
func IsHealthy() bool {
|
||||
logrus.Debugln("requesting health on: " + healthURI)
|
||||
response, err := http.Get(healthURI)
|
||||
defer response.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
logrus.Errorf("requesting Clair health: %v", err)
|
||||
return false
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return false
|
||||
|
@ -89,11 +89,11 @@ func pushLayer(layer v1.LayerEnvelope) error {
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
|
||||
response, err := (&http.Client{}).Do(request)
|
||||
defer response.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("pushing layer to clair: %v", err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode != 201 {
|
||||
if response.StatusCode == 422 {
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
func Versions() (interface{}, error) {
|
||||
Config()
|
||||
response, err := http.Get(uri + "/versions")
|
||||
defer response.Body.Close()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("requesting Clair version: %v", err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
var versionBody interface{}
|
||||
err = json.NewDecoder(response.Body).Decode(&versionBody)
|
||||
|
@ -52,11 +52,11 @@ func AuthenticateResponse(client *http.Client, dockerResponse *http.Response, re
|
||||
req.SetBasicAuth(authConfig.Username, authConfig.Password)
|
||||
|
||||
response, err := client.Do(req)
|
||||
defer response.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode == http.StatusUnauthorized {
|
||||
return ErrUnauthorized
|
||||
|
Loading…
Reference in New Issue
Block a user