{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package layer\n\nPackage layer is package for managing read only and read-write mounts on the union file system driver. Read-only mounts are referenced using a content hash and are protected from mutation in the exposed interface. The tar format is used to create read only layers and export both read only and writable layers. The exported tar data for a read only layer should match the tar used to create the layer.\n\n## Constants\n\n```go\nconst DigestSHA256EmptyTar = DiffID(\"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef\")\n```\nDigestSHA256EmptyTar is the canonical sha256 digest of empty tar file - (1024 NULL bytes)\n\n## Variables\n\n```go\nvar (\n\t// ErrLayerDoesNotExist is used when an operation is\n\t// attempted on a layer which does not exist.\n\tErrLayerDoesNotExist = errors.New(\"layer does not exist\")\n\n\t// ErrLayerNotRetained is used when a release is\n\t// attempted on a layer which is not retained.\n\tErrLayerNotRetained = errors.New(\"layer not retained\")\n\n\t// ErrMountDoesNotExist is used when an operation is\n\t// attempted on a mount layer which does not exist.\n\tErrMountDoesNotExist = errors.New(\"mount does not exist\")\n\n\t// ErrMountNameConflict is used when a mount is attempted\n\t// to be created but there is already a mount with the name\n\t// used for creation.\n\tErrMountNameConflict = errors.New(\"mount already exists with name\")\n\n\t// ErrActiveMount is used when an operation on a\n\t// mount is attempted but the layer is still\n\t// mounted and the operation cannot be performed.\n\tErrActiveMount = errors.New(\"mount still active\")\n\n\t// ErrNotMounted is used when requesting an active\n\t// mount but the layer is not mounted.\n\tErrNotMounted = errors.New(\"not mounted\")\n\n\t// ErrMaxDepthExceeded is used when a layer is attempted\n\t// to be created which would result in a layer depth\n\t// greater than the 125 max.\n\tErrMaxDepthExceeded = errors.New(\"max depth exceeded\")\n)\n```\n\n```go\nvar EmptyLayer = \u0026emptyLayer{}\n```\nEmptyLayer is a layer that corresponds to empty tar.\n\n## Functions\n\n```go\nfunc LogReleaseMetadata(metadatas []Metadata)\n```\nLogReleaseMetadata logs a metadata array, use this to ensure consistent logging for release metadata\n\n```go\nfunc ReleaseAndLog(ls Store, l Layer)\n```\nReleaseAndLog releases the provided layer from the given layer store, logging any error and release metadata\n\n## Types\n\n```go\ntype ChainID digest.Digest\n```\nChainID is the content-addressable ID of a layer.\n\n```go\nfunc CreateChainID(dgsts []DiffID) ChainID\n```\nCreateChainID returns ID for a layerDigest slice\n\n```go\nfunc (id ChainID) String() string\n```\nString returns a string rendition of a layer ID\n\n```go\ntype DiffID digest.Digest\n```\nDiffID is the hash of an individual layer tar.\n\n```go\nfunc (diffID DiffID) String() string\n```\nString returns a string rendition of a layer DiffID\n\n```go\ntype Layer interface {\n\tTarStreamer\n\n\t// ChainID returns the content hash of the entire layer chain. The hash\n\t// chain is made up of DiffID of top layer and all of its parents.\n\tChainID() ChainID\n\n\t// DiffID returns the content hash of the layer\n\t// tar stream used to create this layer.\n\tDiffID() DiffID\n\n\t// Parent returns the next layer in the layer chain.\n\tParent() Layer\n\n\t// Size returns the size of the entire layer chain. The size\n\t// is calculated from the total size of all files in the layers.\n\tSize() (int64, error)\n\n\t// DiffSize returns the size difference of the top layer\n\t// from parent layer.\n\tDiffSize() (int64, error)\n\n\t// Metadata returns the low level storage metadata associated\n\t// with layer.\n\tMetadata() (map[string]string, error)\n}\n```\nLayer represents a read only layer\n\n```go\ntype Metadata struct {\n\t// ChainID is the content hash of the layer\n\tChainID ChainID\n\n\t// DiffID is the hash of the tar data used to\n\t// create the layer\n\tDiffID DiffID\n\n\t// Size is the size of the layer and all parents\n\tSize int64\n\n\t// DiffSize is the size of the top layer\n\tDiffSize int64\n}\n```\nMetadata holds information about a read only layer\n\n```go\ntype MetadataStore interface {\n\t// StartTransaction starts an update for new metadata\n\t// which will be used to represent an ID on commit.\n\tStartTransaction() (MetadataTransaction, error)\n\n\tGetSize(ChainID) (int64, error)\n\tGetParent(ChainID) (ChainID, error)\n\tGetDiffID(ChainID) (DiffID, error)\n\tGetCacheID(ChainID) (string, error)\n\tTarSplitReader(ChainID) (io.ReadCloser, error)\n\n\tSetMountID(string, string) error\n\tSetInitID(string, string) error\n\tSetMountParent(string, ChainID) error\n\n\tGetMountID(string) (string, error)\n\tGetInitID(string) (string, error)\n\tGetMountParent(string) (ChainID, error)\n\n\t// List returns the full list of referenced\n\t// read-only and read-write layers\n\tList() ([]ChainID, []string, error)\n\n\tRemove(ChainID) error\n\tRemoveMount(string) error\n}\n```\nMetadataStore represents a backend for persisting metadata about layers and providing the metadata for restoring a Store.\n\n```go\nfunc NewFSMetadataStore(root string) (MetadataStore, error)\n```\nNewFSMetadataStore returns an instance of a metadata store which is backed by files on disk using the provided root as the root of metadata files.\n\n```go\ntype MetadataTransaction interface {\n\tSetSize(int64) error\n\tSetParent(parent ChainID) error\n\tSetDiffID(DiffID) error\n\tSetCacheID(string) error\n\tTarSplitWriter(compressInput bool) (io.WriteCloser, error)\n\n\tCommit(ChainID) error\n\tCancel() error\n\tString() string\n}\n```\nMetadataTransaction represents functions for setting layer metadata with a single transaction.\n\n```go\ntype MountInit func(root string) error\n```\nMountInit is a function to initialize a writable mount. Changes made here will not be included in the Tar stream of the RWLayer.\n\n```go\ntype RWLayer interface {\n\tTarStreamer\n\n\t// Name of mounted layer\n\tName() string\n\n\t// Parent returns the layer which the writable\n\t// layer was created from.\n\tParent() Layer\n\n\t// Mount mounts the RWLayer and returns the filesystem path\n\t// the to the writable layer.\n\tMount(mountLabel string) (string, error)\n\n\t// Unmount unmounts the RWLayer. This should be called\n\t// for every mount. If there are multiple mount calls\n\t// this operation will only decrement the internal mount counter.\n\tUnmount() error\n\n\t// Size represents the size of the writable layer\n\t// as calculated by the total size of the files\n\t// changed in the mutable layer.\n\tSize() (int64, error)\n\n\t// Changes returns the set of changes for the mutable layer\n\t// from the base layer.\n\tChanges() ([]archive.Change, error)\n\n\t// Metadata returns the low level metadata for the mutable layer\n\tMetadata() (map[string]string, error)\n}\n```\nRWLayer represents a layer which is read and writable\n\n```go\ntype Store interface {\n\tRegister(io.Reader, ChainID) (Layer, error)\n\tGet(ChainID) (Layer, error)\n\tRelease(Layer) ([]Metadata, error)\n\n\tCreateRWLayer(id string, parent ChainID, mountLabel string, initFunc MountInit) (RWLayer, error)\n\tGetRWLayer(id string) (RWLayer, error)\n\tReleaseRWLayer(RWLayer) ([]Metadata, error)\n\n\tCleanup() error\n\tDriverStatus() [][2]string\n\tDriverName() string\n}\n```\nStore represents a backend for managing both read-only and read-write layers.\n\n```go\nfunc NewStoreFromGraphDriver(store MetadataStore, driver graphdriver.Driver) (Store, error)\n```\nNewStoreFromGraphDriver creates a new Store instance using the provided metadata store and graph driver. The metadata store will be used to restore the Store.\n\n```go\nfunc NewStoreFromOptions(options StoreOptions) (Store, error)\n```\nNewStoreFromOptions creates a new Store instance\n\n```go\ntype StoreOptions struct {\n\tStorePath                 string\n\tMetadataStorePathTemplate string\n\tGraphDriver               string\n\tGraphDriverOptions        []string\n\tUIDMaps                   []idtools.IDMap\n\tGIDMaps                   []idtools.IDMap\n}\n```\nStoreOptions are the options used to create a new Store instance\n\n```go\ntype TarStreamer interface {\n\t// TarStream returns a tar archive stream\n\t// for the contents of a layer.\n\tTarStream() (io.ReadCloser, error)\n}\n```\nTarStreamer represents an object which may have its contents exported as a tar stream.\n\n","path":"github.com/hyperhq/hypercli/layer","name":"layer","synopsis":"Package layer is package for managing read only and read-write mounts on the union file system driver.","isRedistributable":true}
