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