Documentation
¶
Index ¶
- Variables
- type ByteRange
- type Keys
- type Packer
- type S3Config
- type StorageLayer
- type Store
- func (s *Store) Get(key string) (data []byte, err error)
- func (s *Store) GetMetadata(key string) (interface{}, error)
- func (s *Store) GetReader(key string) (data io.Reader, err error)
- func (s *Store) ID() string
- func (s *Store) IsClean() bool
- func (s *Store) IsNotExist(err error) bool
- func (s *Store) Open(keys Keys) (err error)
- func (s *Store) Pack(key string) (*Packer, error)
- func (s *Store) Put(key string, data []byte) (written int, err error)
- func (s *Store) PutMetadata(key string, data interface{}) error
- func (s *Store) PutReader(key string, r io.Reader) (written int, err error)
- func (s *Store) Unlock(secret []byte) (keys Keys, err error)
- func (s *Store) Wipe(secret []byte) (keys Keys, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrBadVersion = errors.New("bad version")
Error when retrieving store metadata that has an unknown version.
var ErrForbiddenKey = errors.New("read/write to key name is forbidden")
Error when attempting to read/write to a forbidden key name (e.g. "metadata" which is used internally).
var ErrMalformedMetadata = errors.New("malformed metadata")
Error when retrieving store metadata that's unreadable.
var ErrMissingMetadata = errors.New("user metadata not set")
Error when attempting to read a custom metadata field which hasn't been set.
var ErrStoreNotConnected = errors.New("store not ready for reading/writing")
Error when attempting to read/write from the store before it's been opened, unlocked or wiped.
var ErrStoreNotInitialized = errors.New("remote store not initialized")
Error when attempting to unlock a store which hasn't been initialized.
Functions ¶
This section is empty.
Types ¶
type ByteRange ¶
type ByteRange [2]int
ByteRange is an offset pair (zero-indexed, inclusive) used when requesting partial contents from the storage layer. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35 for more details.
type Keys ¶
type Keys struct {
EncKey []byte `json:"encKey"` // base64 encoded at rest
AuthKey []byte `json:"authKey"` // base64 encoded at rest
}
Keys is a struct for handling the encryption and authentication keys to store data.
type Packer ¶
type Packer struct {
// contains filtered or unexported fields
}
A Packer is used for storing multiple blobs as a single object.
type S3Config ¶
type S3Config struct {
S3Region string `json:"s3Region"`
S3Bucket string `json:"s3Bucket"`
AWSAccessKey string `json:"awsAccessKey"`
AWSSecretKey string `json:"awsSecretKey"`
}
S3Config has the configuration options for creating a new S3 connection.
type StorageLayer ¶
type StorageLayer interface {
// Exists returns true if the container (S3 bucket, folder, etc.) exists and is usable.
Exists() (bool, error)
// Create ensures the container exists and is usable.
Create() error
// Size returns the encrypted content length of an object identified by key.
Size(key string) (int, error)
// GetReader returns the contents of an object identified by key.
GetReader(key string) (io.Reader, error)
// PutReader reads in from r and stores the result to an object.
PutReader(key string, r io.Reader) (int, error)
// IsNotExist returns true if the error indicates an object does not exist.
IsNotExist(err error) bool
}
StorageLayer is the interface used by the store for underlying storage.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles compressing, encrypting and uploading blobs to some storage medium.
func NewStore ¶
func NewStore(layer StorageLayer, id string) *Store
NewStore returns a store using some storage layer.
func NewStoreFS ¶
NewStoreFS returns a store using the filesystem as its storage layer.
func NewStoreS3 ¶
NewStoreS3 returns a store using S3 as its storage layer.
func (*Store) GetMetadata ¶
GetMetadata returns the value of a custom metadata field.
func (*Store) IsClean ¶
IsEmpty returns true if the store is clean (has no metadata) and is thus safe to wipe.
func (*Store) IsNotExist ¶
IsNotExist returns a boolean indicating whether the error is because the object does not exist.
func (*Store) Pack ¶
Pack multiple blobs as a single object in the store. Will overwrite existing keys.
func (*Store) Put ¶
Put some blob as an object in the store. Returns the bytes written. Will overwrite existing keys.
func (*Store) PutMetadata ¶
PutMetadata writes some arbitrary (unencrypted) field to the store metadata. Ideally, this should be some small configuration data or similar.
func (*Store) PutReader ¶
PutReader reads data into an object in the store. Returns the bytes written. Will overwrite existing keys.