Chnage LookupRemoteImage to return error
This commit is patch for following comment // TODO: This method should return the errors instead of masking them and returning false Signed-off-by: Daehyeok Mun <daehyeok@gmail.com> Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
7804b2ca82
commit
b11b1e06e9
2 changed files with 12 additions and 12 deletions
|
@ -102,22 +102,21 @@ func (r *Session) GetRemoteHistory(imgID, registry string, token []string) ([]st
|
|||
}
|
||||
|
||||
// Check if an image exists in the Registry
|
||||
// TODO: This method should return the errors instead of masking them and returning false
|
||||
func (r *Session) LookupRemoteImage(imgID, registry string, token []string) bool {
|
||||
|
||||
func (r *Session) LookupRemoteImage(imgID, registry string, token []string) error {
|
||||
req, err := r.reqFactory.NewRequest("GET", registry+"images/"+imgID+"/json", nil)
|
||||
if err != nil {
|
||||
log.Errorf("Error in LookupRemoteImage %s", err)
|
||||
return false
|
||||
return err
|
||||
}
|
||||
setTokenAuth(req, token)
|
||||
res, _, err := r.doRequest(req)
|
||||
if err != nil {
|
||||
log.Errorf("Error in LookupRemoteImage %s", err)
|
||||
return false
|
||||
return err
|
||||
}
|
||||
res.Body.Close()
|
||||
return res.StatusCode == 200
|
||||
if res.StatusCode != 200 {
|
||||
return utils.NewHTTPRequestError(fmt.Sprintf("HTTP code %d", res.StatusCode), res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Retrieve an image from the Registry.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue