cas

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2015 License: Apache-2.0 Imports: 27 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 FileInfoFromHeader added in v0.5.1

func FileInfoFromHeader(hdr *tar.Header) *fileInfo

func NewHashWriter added in v0.5.1

func NewHashWriter(w io.Writer) specaci.ArchiveWriter

func WriteACIInfo added in v0.4.0

func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error

WriteACIInfo adds or updates the provided aciinfo.

func WriteRemote added in v0.4.0

func WriteRemote(tx *sql.Tx, remote *Remote) error

WriteRemote adds or updates the provided Remote.

Types

type ACIInfo added in v0.4.0

type ACIInfo struct {
	// BlobKey is the key in the blob/imageManifest store of the related
	// ACI file and is the db primary key.
	BlobKey string
	// AppName is the app name provided by the ACI.
	AppName string
	// ImportTime is the time this ACI was imported in the store.
	ImportTime time.Time
	// Latest defines if the ACI was imported using the latest pattern (no
	// version label was provided on ACI discovery)
	Latest bool
}

ACIInfo is used to store information about an ACI.

func GetACIInfosWithAppName added in v0.4.0

func GetACIInfosWithAppName(tx *sql.Tx, appname string) ([]*ACIInfo, bool, error)

GetAciInfosWithAppName returns all the ACIInfos for a given appname. found will be false if no aciinfo exists.

func GetACIInfosWithKeyPrefix added in v0.4.0

func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error)

GetAciInfosWithKeyPrefix returns all the ACIInfos with a blobkey starting with the given prefix.

func NewACIInfo added in v0.4.0

func NewACIInfo(blobKey string, latest bool, t time.Time) *ACIInfo

type DB added in v0.4.0

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

func NewDB added in v0.4.0

func NewDB(dbdir string) (*DB, error)

func (*DB) Begin added in v0.4.0

func (db *DB) Begin() (*sql.Tx, error)

func (*DB) Close added in v0.4.0

func (db *DB) Close() error

func (*DB) Do added in v0.4.0

func (db *DB) Do(fns ...txfunc) error

Do Opens the db, executes DoTx and then Closes the DB

func (*DB) DoTx added in v0.4.0

func (db *DB) DoTx(fns ...txfunc) error

DoTx executes the provided txfuncs inside a unique transaction. If one of the functions returns an error the whole transaction is rolled back.

func (*DB) Open added in v0.4.0

func (db *DB) Open() error

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 GetRemote added in v0.4.0

func GetRemote(tx *sql.Tx, aciURL string) (remote *Remote, found bool, err error)

GetRemote tries to retrieve a remote with the given aciURL. found will be false if remote doesn't exist.

func NewRemote

func NewRemote(aciurl, sigurl string) *Remote

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, error)

func (Store) CheckTreeStore added in v0.5.1

func (ds Store) CheckTreeStore(key string) error

CheckTreeStore verifies the treestore consistency for the specified key.

func (Store) Dump

func (ds Store) Dump(hex bool)

func (Store) GetACI added in v0.4.2

func (ds Store) GetACI(name types.ACName, labels types.Labels) (string, error)

GetACI retrieves the ACI that best matches the provided app name and labels. The returned value is the blob store key of the retrieved ACI. If there are multiple matching ACIs choose the latest one (defined as the last one imported in the store). If no version label is requested, ACIs marked as latest in the ACIInfo are preferred.

func (Store) GetImageManifest added in v0.4.0

func (ds Store) GetImageManifest(key string) (*schema.ImageManifest, error)

Get the ImageManifest with the specified key.

func (Store) GetRemote added in v0.4.0

func (ds Store) GetRemote(aciURL string) (*Remote, bool, error)

GetRemote tries to retrieve a remote with the given ACIURL. found will be false if remote doesn't exist.

func (Store) GetTreeStorePath added in v0.5.1

func (ds Store) GetTreeStorePath(key string) string

GetTreeStorePath returns the absolute path of the treestore for the specified key. It doesn't ensure that the path exists and is fully rendered. This should be done calling IsRendered()

func (Store) GetTreeStoreRootFS added in v0.5.1

func (ds Store) GetTreeStoreRootFS(key string) string

GetTreeStoreRootFS returns the absolute path of the rootfs in the treestore for specified key. It doesn't ensure that the rootfs exists and is fully rendered. This should be done calling IsRendered()

func (Store) HashToKey added in v0.4.0

func (ds Store) 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.

func (Store) ReadStream

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

func (Store) RenderTreeStore added in v0.5.1

func (ds Store) RenderTreeStore(key string, rebuild bool) error

RenderTreeStore renders a treestore for the given image key if it's not already fully rendered. Users of treestore should call ds.RenderTreeStore before using it to ensure that the treestore is completely rendered.

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) TmpDir added in v0.5.3

func (ds Store) TmpDir() (string, error)

TmpDir creates and returns dir local to the same filesystem as the Store, or any error encountered

func (Store) TmpFile added in v0.5.3

func (ds Store) TmpFile() (*os.File, error)

TmpFile returns an *os.File local to the same filesystem as the Store, or any error encountered

func (Store) WriteACI

func (ds Store) WriteACI(r io.Reader, latest bool) (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) latest defines if the aci has to be marked as the latest. For example an ACI discovered without asking for a specific version (latest pattern).

func (Store) WriteRemote added in v0.4.0

func (ds Store) WriteRemote(remote *Remote) error

WriteRemote adds or updates the provided Remote.

type TreeStore added in v0.5.1

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

TreeStore represents a store of rendered ACIs The image's key becomes the name of the directory containing the rendered aci.

func (*TreeStore) Check added in v0.5.1

func (ts *TreeStore) Check(key string) error

Check calculates the actual rendered ACI's hash and verifies that it matches the saved value.

func (*TreeStore) GetPath added in v0.5.1

func (ts *TreeStore) GetPath(key string) string

GetPath returns the absolute path of the treestore for the specified key. It doesn't ensure that the path exists and is fully rendered. This should be done calling IsRendered()

func (*TreeStore) GetRootFS added in v0.5.1

func (ts *TreeStore) GetRootFS(key string) string

GetRootFS returns the absolute path of the rootfs for the specified key. It doesn't ensure that the rootfs exists and is fully rendered. This should be done calling IsRendered()

func (*TreeStore) Hash added in v0.5.1

func (ts *TreeStore) Hash(key string) (string, error)

TreeStore calculates an hash of the rendered ACI. It uses the same functions used to create a tar but instead of writing the full archive is just computes the sha512 sum of the file infos and contents.

func (*TreeStore) IsRendered added in v0.5.1

func (ts *TreeStore) IsRendered(key string) (bool, error)

IsRendered checks if the tree store is fully rendered

func (*TreeStore) Remove added in v0.5.1

func (ts *TreeStore) Remove(key string) error

Remove cleans the directory for the specified key

func (*TreeStore) Write added in v0.5.1

func (ts *TreeStore) Write(key string, ds *Store) error

Write renders the ACI with the provided key in the treestore Write, to avoid having a rendered ACI with old stale files, requires that the destination directory doesn't exist (usually Remove should be called before Write)

Jump to

Keyboard shortcuts

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