forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
40 lines (32 loc) · 1.12 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
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package binarystorage
import (
"io"
)
// Metadata describes a binary file stored in the storage.
type Metadata struct {
Version string
Size int64
SHA256 string
}
// Storage provides methods for storing and retrieving binary files by version.
type Storage interface {
// Add adds the binary file and metadata into state, replacing existing
// metadata if any exists with the specified version.
Add(io.Reader, Metadata) error
// Open returns the Metadata and binary file contents for the specified
// version if it exists, else an error satisfying errors.IsNotFound.
Open(version string) (Metadata, io.ReadCloser, error)
// AllMetadata returns metadata for the full list of binary files in the
// catalogue.
AllMetadata() ([]Metadata, error)
// Metadata returns the Metadata for the specified version if it exists,
// else an error satisfying errors.IsNotFound.
Metadata(version string) (Metadata, error)
}
// StorageCloser extends the Storage interface with a Close method.
type StorageCloser interface {
Storage
Close() error
}