-
Notifications
You must be signed in to change notification settings - Fork 0
/
blob.go
41 lines (32 loc) · 785 Bytes
/
blob.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package client
import (
"io"
"net/http"
"path"
"github.com/opencontainers/go-digest"
)
type Blob interface {
GetBlob(repo string, digest digest.Digest) (io.Reader, error)
DeleteBlob(repo string, digest digest.Digest) error
PutBlob(repo string, digest digest.Digest, blob io.Writer) error
}
// VerifyBlob confirms the existance of a manifest in a remote registry.
func (api *DistributionAPI) VerifyBlob(
repo string, digest digest.Digest) error {
c := api.client
u := *c.Host
u.Path = path.Join("/v2", repo, "blobs", digest.String())
req := &http.Request{
Method: "HEAD",
URL: &u,
Header: make(http.Header),
}
resp, err := c.RoundTrip(req)
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return ErrBlobNotExist
}
return nil
}