Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions docker/docker_image_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down