Documentation ¶
Overview ¶
Package store 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 ¶
- Variables
- func RemoveACIInfo(tx *sql.Tx, blobKey string) error
- func RemoveRemote(tx *sql.Tx, blobKey string) error
- func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error
- func WriteRemote(tx *sql.Tx, remote *Remote) error
- type ACIFetchInfo
- type ACIInfo
- func GetACIInfoWithBlobKey(tx *sql.Tx, blobKey string) (*ACIInfo, bool, error)
- func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error)
- func GetACIInfosWithName(tx *sql.Tx, name string) ([]*ACIInfo, bool, error)
- func GetAllACIInfos(tx *sql.Tx, sortfields []string, ascending bool) ([]*ACIInfo, error)
- func NewACIInfo(blobKey string, latest bool, t time.Time, size int64, treeStoreSize int64) *ACIInfo
- type ACINotFoundError
- type Remote
- type Store
- func (s *Store) Close() error
- func (s *Store) Dump(hex bool)
- func (s *Store) GetACI(name types.ACIdentifier, labels types.Labels) (string, error)
- func (s *Store) GetACIInfoWithBlobKey(blobKey string) (*ACIInfo, error)
- func (s *Store) GetAllACIInfos(sortfields []string, ascending bool) ([]*ACIInfo, error)
- func (s *Store) GetAllRemotes() ([]*Remote, error)
- func (s *Store) GetImageManifest(key string) (*schema.ImageManifest, error)
- func (s *Store) GetImageManifestJSON(key string) ([]byte, error)
- func (s *Store) GetRemote(aciURL string) (*Remote, bool, error)
- func (s *Store) HasFullKey(key string) bool
- func (s *Store) HashToKey(h hash.Hash) string
- func (s *Store) ReadStream(key string) (io.ReadCloser, error)
- func (s *Store) RemoveACI(key string) error
- func (s *Store) ResolveKey(key string) (string, error)
- func (s *Store) ResolveName(name string) ([]string, bool, error)
- func (s *Store) TmpDir() (string, error)
- func (s *Store) TmpFile() (*os.File, error)
- func (s Store) TmpNamedFile(name string) (*os.File, error)
- func (s *Store) UpdateTreeStoreSize(key string, newSize int64) error
- func (s *Store) WriteACI(r io.ReadSeeker, fetchInfo ACIFetchInfo) (string, error)
- func (s *Store) WriteRemote(remote *Remote) error
- type StoreRemovalError
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = errors.New("no image IDs found") ErrDBUpdateNeedsRoot = errors.New("database schema needs to be updated, re-run as root to perform the update") )
Functions ¶
func RemoveACIInfo ¶
RemoveACIInfo removes the ACIInfo with the given blobKey.
func RemoveRemote ¶
RemoveRemote removes the remote with the given blobKey.
func WriteACIInfo ¶
WriteACIInfo adds or updates the provided aciinfo.
Types ¶
type ACIFetchInfo ¶
type ACIFetchInfo struct { // Latest defines if the ACI was imported using the latest pattern // (no version label was provided on ACI discovery). Latest bool }
ACIFetchInfo is used to store information about the fetching process of an ACI.
type ACIInfo ¶
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 // Name is the name of the ACI. Name string // ImportTime is the time this ACI was imported in the store. ImportTime time.Time // LastUsed is the last time this image was read LastUsed time.Time // Size is the size in bytes of this image in the store Size int64 // TreeStoreSize is the size in bytes of this image in the tree store TreeStoreSize int64 // 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 GetACIInfoWithBlobKey ¶
GetAciInfosWithBlobKey returns the ACIInfo with the given blobKey. found will be false if no aciinfo exists.
func GetACIInfosWithKeyPrefix ¶
GetAciInfosWithKeyPrefix returns all the ACIInfos with a blobkey starting with the given prefix.
func GetACIInfosWithName ¶
GetAciInfosWithName returns all the ACIInfos for a given name. found will be false if no aciinfo exists.
func GetAllACIInfos ¶
GetAllACIInfos returns all the ACIInfos sorted by optional sortfields and with ascending or descending order.
type ACINotFoundError ¶
type ACINotFoundError struct {
// contains filtered or unexported fields
}
ACINotFoundError is returned when an ACI cannot be found by GetACI Useful to distinguish a generic error from an aci not found.
func (ACINotFoundError) Error ¶
func (e ACINotFoundError) Error() string
type Remote ¶
type Remote struct { // ACIURL is the URL used to import an ACI. ACIURL string // SigURL is the URL used to import an ACI verification signature. SigURL string ETag string // The key in the blob store under which the ACI has been saved. BlobKey string CacheMaxAge int DownloadTime time.Time }
func GetAllRemotes ¶
GetAllRemotes returns all the ACIInfos sorted by optional sortfields and with ascending or descending order.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store encapsulates a content-addressable-storage for storing ACIs on disk.
func (*Store) GetACI ¶
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) GetACIInfoWithBlobKey ¶
func (*Store) GetAllACIInfos ¶
func (*Store) GetAllRemotes ¶
func (*Store) GetImageManifest ¶
func (s *Store) GetImageManifest(key string) (*schema.ImageManifest, error)
GetImageManifest gets the ImageManifest with the specified key.
func (*Store) GetImageManifestJSON ¶
GetImageManifestJSON gets the ImageManifest JSON bytes with the specified key.
func (*Store) GetRemote ¶
GetRemote tries to retrieve a remote with the given ACIURL. found will be false if remote doesn't exist.
func (*Store) HasFullKey ¶ added in v1.13.0
HasFullKey returns whether the image with the given key exists on the disk by checking if the image manifest kv store contains the key.
func (*Store) HashToKey ¶
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 (s *Store) ReadStream(key string) (io.ReadCloser, error)
func (*Store) RemoveACI ¶
RemoveACI removes the ACI with the given key. It firstly removes the aci infos inside the db, then it tries to remove the non transactional data. If some error occurs removing some non transactional data a StoreRemovalError is returned.
func (*Store) ResolveKey ¶
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) ResolveName ¶
ResolveName resolves an image name to a list of full keys and using the store for resolution.
func (*Store) TmpDir ¶
TODO(sgotti), unexport this and provide other functions for external users TmpDir creates and returns dir local to the same filesystem as the Store, or any error encountered
func (*Store) TmpFile ¶
TODO(sgotti), unexport this and provide other functions for external users TmpFile returns an *os.File local to the same filesystem as the Store, or any error encountered
func (Store) TmpNamedFile ¶
TODO(sgotti), unexport this and provide other functions for external users TmpNamedFile returns an *os.File with the specified name local to the same filesystem as the Store, or any error encountered. If the file already exists it will return the existing file in read/write mode with the cursor at the end of the file.
func (*Store) UpdateTreeStoreSize ¶
TODO(sgotti) remove this when the treestore will save its images' sizes by itself
func (*Store) WriteACI ¶
func (s *Store) WriteACI(r io.ReadSeeker, fetchInfo ACIFetchInfo) (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 ¶
WriteRemote adds or updates the provided Remote.
type StoreRemovalError ¶
type StoreRemovalError struct {
// contains filtered or unexported fields
}
StoreRemovalError defines an error removing a non transactional store (like a diskv store). When this happen there's the possibility that the store is left in an unclean state (for example with some stale files).
func (*StoreRemovalError) Error ¶
func (e *StoreRemovalError) Error() string