cas

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2015 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package cas implements a content-addressable-store on disk. It leverages the `diskv` package to store items in a simple key-value blob store: https://github.com/peterbourgon/diskv

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashToKey added in v0.2.0

func HashToKey(h hash.Hash) string

HashToKey takes a hash.Hash (which currently _MUST_ represent a full SHA512), calculates its sum, and returns a string which should be used as the key to store the data matching the hash.

Types

type Index

type Index interface {
	Hash() string
	Marshal() []byte
	Unmarshal([]byte)
	Type() int64
}

type Remote

type Remote struct {
	ACIURL string
	SigURL string
	ETag   string
	// The key in the blob store under which the ACI has been saved.
	BlobKey string
}

func NewRemote

func NewRemote(aciurl, sigurl string) *Remote

func (Remote) Download

func (r Remote) Download(ds Store, ks *keystore.Keystore) (*openpgp.Entity, *os.File, error)

Download downloads and verifies the remote ACI. If Keystore is nil signature verification will be skipped. Download returns the signer, an *os.File representing the ACI, and an error if any. err will be nil if the ACI downloads successfully and the ACI is verified.

func (Remote) Hash

func (r Remote) Hash() string

func (Remote) Marshal

func (r Remote) Marshal() []byte

func (Remote) Store added in v0.2.0

func (r Remote) Store(ds Store, aci io.Reader) (*Remote, error)

TODO: add locking Store stores the ACI represented by r in the target data store.

func (Remote) Type

func (r Remote) Type() int64

func (*Remote) Unmarshal

func (r *Remote) Unmarshal(data []byte)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store encapsulates a content-addressable-storage for storing ACIs on disk.

func NewStore

func NewStore(base string) *Store

func (Store) Dump

func (ds Store) Dump(hex bool)

func (Store) ReadIndex

func (ds Store) ReadIndex(i Index) error

func (Store) ReadStream

func (ds Store) ReadStream(key string) (io.ReadCloser, error)

func (Store) ResolveKey added in v0.2.0

func (ds Store) ResolveKey(key string) (string, error)

ResolveKey resolves a partial key (of format `sha512-0c45e8c0ab2`) to a full key by considering the key a prefix and using the store for resolution. If the key is longer than the full key length, it is first truncated.

func (Store) WriteACI

func (ds Store) WriteACI(r io.Reader) (string, error)

WriteACI takes an ACI encapsulated in an io.Reader, decompresses it if necessary, and then stores it in the store under a key based on the image ID (i.e. the hash of the uncompressed ACI)

func (Store) WriteIndex

func (ds Store) WriteIndex(i Index)

func (Store) WriteStream

func (ds Store) WriteStream(key string, r io.Reader) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL