vendor containers/image for better registry errors

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca
2016-10-12 10:55:13 +02:00
parent d166555fb4
commit a48f7597e3
60 changed files with 9148 additions and 22 deletions

View File

@@ -13,18 +13,9 @@ import (
"github.com/Sirupsen/logrus"
"github.com/containers/image/manifest"
"github.com/containers/image/types"
"github.com/docker/distribution/registry/client"
)
// ErrFetchManifest provides the error when fetching the manifest fails
type ErrFetchManifest struct {
statusCode int
body []byte
}
func (e ErrFetchManifest) Error() string {
return fmt.Sprintf("error fetching manifest: status code: %d, body: %s", e.statusCode, string(e.body))
}
type dockerImageSource struct {
ref dockerReference
requestedManifestMIMETypes []string
@@ -93,13 +84,13 @@ func (s *dockerImageSource) fetchManifest(tagOrDigest string) ([]byte, string, e
return nil, "", err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, "", client.HandleErrorResponse(res)
}
manblob, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, "", err
}
if res.StatusCode != http.StatusOK {
return nil, "", ErrFetchManifest{res.StatusCode, manblob}
}
return manblob, simplifyContentType(res.Header.Get("Content-Type")), nil
}