Documentation
¶
Overview ¶
Package bundle implements a provider to extract, parse, and manage bundles.
Basic Example:
cachePath := "./cache" bundleStore := store.NewSimpleStore(cachePath) bundlePath := "bundle" prefixPath := "prefix" bundleProvider := bundle.NewProvider(bundleStore) b, _ := bundleProvider.GetBundle(bundlePath) b.SourceCommand()
Index ¶
Constants ¶
const ( ErrorTypeContentID = "CONTENT_ID" ErrorTypeSource = "SOURCE" ErrorTypeFormat = "FORMAT" ErrorTypeExtraction = "EXTRACTION" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle interface {
// List of commands that should be executed
// to insert the bundle's contents into
// a shell environment
SourceCommands() []string
// List of commands that should be executed
// to insert the bundle's contents into
// a POSIX-standard environment
PosixSourceCommands() []string
// List of commands that should be executed
// to insert the bundle's contents into
// a shell-standard environment
//
// The root path in the source commands will be replaced with location.
// This is useful if you mount the store in a container want to access them in the container's mounted location.
SourceCommandsUsingLocation(location string) []string
// List of commands that should be executed
// to insert the bundle's contents into
// a POSIX-standard environment
//
// The root path in the source commands will be replaced with location.
// This is useful if you mount the store in a container want to access them in the container's mounted location.
PosixSourceCommandsUsingLocation(location string) []string
// Releases all resources that this bundle holds
Release()
}
Bundle provides the source commands to apply the bundle's contents to the local environment
type Cache ¶
type Cache interface {
// Put a key into the storeItems, with it's corresponding contents.
// If a key already exists, we ignore the Put command, in order to prevent double work.
// A reader is passed in, so that BundleCache can write the contents, and Extract to disk.
// an extractor is passed in so that bundle can call the extractor to Extract
//
// By default, a Put will set the item to "protected"
//
// Returns:
// result for GetPath for this item that is put.
// error if there are Extract errors
Put(key string, extractor Extractor) (string, error)
// Load existing keys into memory from disk.
// The initial key load into memory refcount is 0
// Return:
// error if key doesn't exist on disk
Load(keys []string) error
// Given a key, get the root path to the extracted files.
// An empty string "" is returned if the key doesn't exist.
GetPath(key string) string
// Given a key, does it exist in the storeItems?
Exists(key string) bool
// Return the root path of the store
RootPath() string
// Get keys from in use (refcount > 0) storeItems
GetInUseItemKeys() []string
// Tell the store that we're done with this item
Release(key string) error
// Deletes storage space of items that are unreferenced
Cleanup()
}
Cache manages the contents of bundles in the local filesystem. Every entry in the storeItems is a directory containing extracted files that bundle uses. The key is a key that uniquely identifies the group of extracted files. Each entry can be a versioned sub-part or a versioned full part of a bundle.
type Extractor ¶
type Extractor interface {
// Extract contents to extractLocation using fs to write to the local file system.
Extract(extractLocation string, fs fs.FileSystem) error
}
Extractor extracts all its contents of an archive into the target location
type ProgressCallback ¶
ProgressCallback returns information about the download and extraction of the bundle to the caller.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider accepts a URL pointing at a bundle and returns the corresponding bundle object. It supports fetching from any URL supported by URLToStream.
func NewProvider ¶
NewProvider creates a provider which uses the passed in Cache as storage for extracted bundles.
func (*Provider) GetBundle ¶
GetBundle fetches and extracts the bundle pointed to by url and returns its representation.
func (*Provider) GetVersionedBundle ¶
GetVersionedBundle fetches and extracts the bundle pointed to by URL and verifies its hash matches the passed in expectedContentID. For S3 downloads the etag is used.
func (*Provider) SetProgressCallback ¶
func (b *Provider) SetProgressCallback(callback ProgressCallback)
SetProgressCallback accepts a function to be invoked at regular intervals during download and extraction.
func (*Provider) SetProgressCallbackRate ¶
SetProgressCallbackRate sets the rate in seconds the progress callback should be invoked.