-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
68 lines (62 loc) · 2.36 KB
/
interface.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package blobstore
import (
"crypto"
"io"
)
// Store is the interface for managing image manifest and rootfs diff blobs.
// Any errors returned by this interface are of type Error.
type Store interface {
// Get the blob with the given digest from this store.
Get(digest string) (Blob, error)
// List returns a slice of digest strings for each blob in this store.
List() ([]string, error)
// NewWriter begins the process of writing a new blob using the given hash
// to compute the digest.
NewWriter(crypto.Hash) (BlobWriter, error)
// Ref increments the reference count for the blob with the given digest.
Ref(digest string) (Descriptor, error)
// Deref decrements the reference count for the blob with the given digest.
// If no references to the blob remain, the blob will be removed from the
// store and blobs to which it links will also be dereferenced.
Deref(digest string) error
// Link sets up a link between the blobs referenced by digests *to* and
// *from*. Assumes an implicit reference from *from* to *to*.
Link(to, from string) error
// Unlink removes a link between the blobs referenced by digests *to* and
// *from*. Also dereferences the *to* blob.
Unlink(to, from string) error
}
// BlobWriter provides a handle for writing a new blob to the blob store.
type BlobWriter interface {
io.Writer
// Digest returns the digest of the data which has been written so far.
Digest() string
// Commit completes the blob writing process. The new blob is stored with
// the given mediaType and starting refcount of 1. If another blob already
// exists with the same computed digest then the reference is added to that
// blob. If there is an error, it is of type Error.
Commit() (Descriptor, error)
// Cancel ends the writing process, cleaning up any temporary resources. If
// there is an error, it is of type *Error.
Cancel() error
}
// Descriptor describes a blob.
type Descriptor interface {
Digest() string
Size() uint64
RefCount() uint64
Links() (linksTo []string)
}
// Blob is the interface for accessing a blob.
type Blob interface {
Descriptor
// Open should open the underlying blob for reading. It is the
// responsibility of the caller to close the returned io.ReadCloser.
// Returns a nil error on success.
Open() (io.ReadCloser, error)
}
// Error is the error type returned by the Store interface.
type Error interface {
error
IsBlobNotExists() bool
}