Documentation
¶
Overview ¶
Package bottle implements the local bottle handling functionality, providing facilities for:
- loading, storing, configuring, and validating bottle metadata (using external schema definition). - managing part information, synchronizing local and remote data as well as tracking part changes. - working with bottle and part labels and the local representation of part labels on local storage. - managing virtual parts (those that exist in a bottle, but have not been transferred locally due to selector use). - facilitating telemetry functionality with bottleID and telemetry events.
Index ¶
- Constants
- Variables
- func CheckIfCanInitialize(bottlePath string, force bool) error
- func CopyFromCache(ctx context.Context, btl *Bottle, desc ocispec.Descriptor, name string, ...) (bool, error)
- func CreateBottle(bottlePath string, overwrite bool) error
- func EntryFile(path string) string
- func FindBottleRootDir(inputPath string) (string, error)
- func InspectBottleFiles(ctx context.Context, btl *Bottle, opts Options) (string, bool, error)
- func ReadBottleIDFile(bottlePath string) (digest.Digest, error)
- func SaveBottleConfig(btl *Bottle) error
- func SaveBottleID(btl *Bottle) error
- func SaveBottleIDFile(btl *Bottle, path string) error
- func SaveBottleManifest(btl *Bottle) error
- func SaveExtraBottleInfo(ctx context.Context, btl *Bottle) error
- func SavePullCmd(ctx context.Context, btl *Bottle) error
- func SaveUpdatesToSet(ctx context.Context, btl *Bottle, options SaveOptions) error
- func SigDir(path string) string
- func VerifyPullDir(destdir string) error
- func WithVirtualParts(btl *Bottle) error
- type BOption
- type Bottle
- func (btl *Bottle) AddAnnotation(k, v string)
- func (btl *Bottle) AddArtifact(name, pth, mediaType string, dgst digest.Digest) error
- func (btl *Bottle) AddAuthorInfo(authorIn cfgdef.Author) error
- func (btl *Bottle) AddLabel(k, v string)
- func (btl *Bottle) AddMetricInfo(metricIn cfgdef.Metric) error
- func (btl *Bottle) AddPartLabel(ctx context.Context, key, value, partPath string) error
- func (btl *Bottle) AddPartMetadata(name string, contentSize int64, contentDigest digest.Digest, layerSize int64, ...)
- func (btl *Bottle) AddSourceInfo(sourceIn cfgdef.Source) error
- func (btl *Bottle) BIC() cache.BIC
- func (btl *Bottle) CalculatePublicArtifactDigest(index int) error
- func (btl *Bottle) ConfigDescriptor() (ocispec.Descriptor, error)
- func (btl *Bottle) Configure(cfgData []byte) error
- func (btl *Bottle) ConfigureFromFile(filePath string) error
- func (btl *Bottle) ConstructManifest() error
- func (btl *Bottle) DeprecateBottleID(bottleID digest.Digest)
- func (btl *Bottle) GetBottleID() digest.Digest
- func (btl *Bottle) GetBottleManifest() ([]byte, error)
- func (btl *Bottle) GetCache() orascontent.GraphStorage
- func (btl *Bottle) GetConfigPath() string
- func (btl *Bottle) GetConfiguration() ([]byte, error)
- func (btl *Bottle) GetManifestAnnotations() map[string]string
- func (btl *Bottle) GetManifestArtifactType() string
- func (btl *Bottle) GetManifestPath() string
- func (btl *Bottle) GetPartByLayerDescriptor(descriptor ocispec.Descriptor) PartInfo
- func (btl *Bottle) GetPartByName(partName string) PartInfo
- func (btl *Bottle) GetPartStatus(ctx context.Context, search PartTrack) PartStatus
- func (btl *Bottle) GetParts() []PartInfo
- func (btl *Bottle) GetPath() string
- func (btl *Bottle) LoadLocalLabels() error
- func (btl *Bottle) NativePath(pth string) string
- func (btl *Bottle) NumParts() int
- func (btl *Bottle) PartDescriptors() ([]ocispec.Descriptor, error)
- func (btl *Bottle) RemoveAnnotation(k string) error
- func (btl *Bottle) RemoveArtifact(pth string) error
- func (btl *Bottle) RemoveAuthorInfo(name string) error
- func (btl *Bottle) RemoveLabel(k string) error
- func (btl *Bottle) RemoveMetricInfo(metricName string) error
- func (btl *Bottle) RemovePartLabel(ctx context.Context, key, partPath string) error
- func (btl *Bottle) RemovePartMetadata(name string)
- func (btl *Bottle) RemoveSourceInfo(name string) error
- func (btl *Bottle) Save() error
- func (btl *Bottle) ScratchPath() string
- func (btl *Bottle) SetDescription(content string)
- func (btl *Bottle) SetManifest(manifest oci.ManifestHandler)
- func (btl *Bottle) SetRawManifest(inData []byte)
- func (btl *Bottle) Touch()
- func (btl *Bottle) UpdatePartMetadata(name string, contentSize int64, contentDigest digest.Digest, ...)
- func (btl *Bottle) VerifyBottleID(matchBottleID digest.Digest) error
- type Options
- type PartInfo
- type PartSelectorFunc
- type PartSelectorOptions
- type PartStatus
- type PartTrack
- func (p *PartTrack) GetContentDigest() digest.Digest
- func (p *PartTrack) GetContentSize() int64
- func (p *PartTrack) GetLabels() labels.Set
- func (p *PartTrack) GetLayerDigest() digest.Digest
- func (p *PartTrack) GetLayerSize() int64
- func (p *PartTrack) GetMediaType() string
- func (p *PartTrack) GetModTime() time.Time
- func (p *PartTrack) GetName() string
- func (p *PartTrack) SetLayerDigest(dgst digest.Digest)
- func (p *PartTrack) SetLayerSize(sz int64)
- func (p *PartTrack) SetMediaType(mt string)
- func (p *PartTrack) SetModTime(mtime time.Time)
- type SaveOptions
- type VirtRecord
- type VirtualParts
- type Visitor
Constants ¶
const VirtTrackingFile = "vlayers.json"
VirtTrackingFile is the filename for local virtual parts tracking json file.
Variables ¶
var ( // ErrDirNotEmpty is return when a directory that is found not to be empty. ErrDirNotEmpty = errors.New("directory is not empty") // ErrPartInsecureArchive is an error that indicates that a part contains a directory archive but does not include // a trailing slash in the name. This can enable aliasing of files and directories by an attacker or otherwise, as // mentioned in https://git.act3-ace.com/ace/data/tool/-/issues/314 ErrPartInsecureArchive = errors.New("part is named as regular file, but is an archived directory media type") )
var ErrBottleAlreadyInit = errors.New("bottle already initialized")
ErrBottleAlreadyInit is the error received when trying to init an inited bottle.
var ErrDirNestedInBottle = errors.New("path is nested within bottle directory")
ErrDirNestedInBottle indicates that the destination of the bottle already has a bottle.
var ErrUnknownLayerMediaType = errors.New("unknown layer media type")
ErrUnknownLayerMediaType is the error if the layer media type is unknown.
Functions ¶
func CheckIfCanInitialize ¶
CheckIfCanInitialize examines the provided path and determines if the bottle is already initialized (allowing reinit if force is on), or if there is an error initializing.
func CopyFromCache ¶
func CopyFromCache(ctx context.Context, btl *Bottle, desc ocispec.Descriptor, name string, btlPartMutex *sync.Mutex) (bool, error)
CopyFromCache copies a bottle part from the cache, handling extraction and decompression based on part mediatypes.
func CreateBottle ¶
CreateBottle creates a bottle configuration yaml, including creating the path to the yaml file (as determined by the bottle library). It then determines if the set can be initialized, and if so, creates a new bottle config file.
func FindBottleRootDir ¶
FindBottleRootDir checks if the current path is nested within a bottle, and returns the root directory of a bottle. If root bottle is not found, the function return the input path, along with an error.
func InspectBottleFiles ¶
InspectBottleFiles files iterates over all the files in a directory, including subdirectories, and determines if the files are cached, new, or updated. Returns a string containing bottle info if opts specifies display. Also returns a boolean that is true if files changed.
func ReadBottleIDFile ¶
ReadBottleIDFile reads and parses the bottle id file of the bottle.
func SaveBottleConfig ¶
SaveBottleConfig saves a json representation of the bottle to the local bottle configuration directory.
func SaveBottleID ¶
SaveBottleID writes a bottle id as "<algorithm>:<digest>" to the bottle's bottleid file.
func SaveBottleIDFile ¶
SaveBottleIDFile writes a bottle id as "<algorithm>:<digest>" to a given file.
func SaveBottleManifest ¶
SaveBottleManifest writes a bottle's manifest as raw json to the bottle's manifest file (.dt/manifest.json).
func SaveExtraBottleInfo ¶
SaveExtraBottleInfo saves the bottle ID and config JSON and the pull command used This data is never read by ace-dt and is only saved as a convenience to the user.
func SavePullCmd ¶
SavePullCmd writes a pull command using the bottle digest as source, and including part selectors if there are any virtual parts. This function is safe to call in any bottle command, and will log any errors instead of returning them.
func SaveUpdatesToSet ¶
func SaveUpdatesToSet(ctx context.Context, btl *Bottle, options SaveOptions) error
SaveUpdatesToSet performs archival, digest, and cache commission to bottle components, and saves bottle metadata.
func VerifyPullDir ¶
VerifyPullDir performs checks on the bottle destination path to ensure that it meets the expected criteria.
func WithVirtualParts ¶
WithVirtualParts populates a virtual part tracker with virtual part information found in a bottle config directory.
Types ¶
type BOption ¶
BOption defines a function that operates on a Bottle to configure options A variadic list fo BottleOptions is provided to the Bottle constructor to set desired options (and use defaults for the rest).
func DisableCache ¶
DisableCache sets or clears a flag that optionally disables the usage of cache storage. This is primarily intended for use when no data transfer is expected for bottle items (such as when performing a remote query).
func DisableDestinationCreate ¶
DisableDestinationCreate sets or clears a flag that optionally disables the creation of an output path before transfer. This only pertains to Bottle downloads.
func WithBlobInfoCache ¶
WithBlobInfoCache defines a file path where a blob info cache is discovered or created, usually this will be in the cache path. If an empty string is provided, a memory based BIC will be used.
func WithCachePath ¶
WithCachePath defines a file path where Bottle blobs are stored during download and upload.
func WithLocalLabels ¶
func WithLocalLabels() BOption
WithLocalLabels populates the bottle label provider with the labels found in .labels.yaml files on the filesystem, located in the provided path.
func WithLocalPartFile ¶
WithLocalPartFile specifies a local part file path for reading local part metadata, this function does not update the bottle definition with the part information, use SyncDefinitionParts after calling this if needed.
func WithLocalPath ¶
WithLocalPath defines a local path for a Bottle, which can be the destination for a download or source for upload.
type Bottle ¶
type Bottle struct { Manifest oci.ManifestHandler // Definition is the bottle configuration. // Outside of methods of this package, Definition must not be modified Definition cfgdef.Bottle // OriginalManifest is the manifest that was pulled OriginalManifest []byte // OriginalConfig is the config that was pulled OriginalConfig []byte // Parts is the complete list of parts (local and virtual) for this bottle Parts []PartTrack VirtualPartTracker *VirtualParts DisableCreateDestDir bool // contains filtered or unexported fields }
Bottle represents a bottle and associated options for managing data transfer. The options are set using BottleOption functional options in a call to NewBottle constructor.
func LoadBottle ¶
LoadBottle attempts to load an existing bottle configuration from the provided bottle path. opts provides a method to override the default bottle configuration. LocalPath and YAML file options will be set by the path argument, so will not need to be supplied.
func NewBottle ¶
NewBottle creates a new Bottle and prepares it for transfer using the Bottle.Get function. The created bottle is configured with the options provided, which are any number of functional options. For functionality, at least remote source and local path should be defined in the option list. If not disabled, the output directory is created during construction.
func NewReadOnlyBottle ¶
NewReadOnlyBottle creates a bottle without initializing any features that would produce side effects, such as creating directories, initializing authentication, performing local metadata initializations. Despite the name, a read only bottle can be modified after creation, such as configuring with config data or modifying bottle settings directly.
func (*Bottle) AddAnnotation ¶
AddAnnotation adds input key, and value to a bottle annotations map in the bottle schema.
func (*Bottle) AddArtifact ¶
AddArtifact adds a public artifact to the bottle definition. The artifact is keyed on a path. If the artifact passed in is found in the definition, the item is updated. If no changes are found, then the function returns without making any changes to the bottle definition. If a field of the bottle is invalid, an error is returned.
func (*Bottle) AddAuthorInfo ¶
AddAuthorInfo adds an authors to the bottle's list of authors If the name or the email being added matches an existing author that author entry is updated Returns an error when input is invalid.
func (*Bottle) AddMetricInfo ¶
AddMetricInfo adds a metric to the bottle's list of metrics. If the name of the input metric matches an already present metrics, then the metric is updated. Return an error if the input metric fails validation.
func (*Bottle) AddPartLabel ¶
AddPartLabel adds a label to a part listed in the bottle. Part labels are added to LocalPart labels map, then synced to the bottle definitions.
func (*Bottle) AddPartMetadata ¶
func (btl *Bottle) AddPartMetadata(name string, contentSize int64, contentDigest digest.Digest, layerSize int64, layerDigest digest.Digest, mediaType string, modtime time.Time, )
AddPartMetadata adds information about a part to the bottle.
func (*Bottle) AddSourceInfo ¶
AddSourceInfo adds a source to the bottle's list of sources If the name or the uri matches an already available source, then the item is updated. Return an error if the input source fails validation.
func (*Bottle) CalculatePublicArtifactDigest ¶
CalculatePublicArtifactDigest updates the artifact at the specified index with the digest of the corresponding file.
func (*Bottle) ConfigDescriptor ¶
func (btl *Bottle) ConfigDescriptor() (ocispec.Descriptor, error)
ConfigDescriptor returns an oci descriptor for a bottle config, as it corresponds to the config in a manifest.
func (*Bottle) Configure ¶
Configure configures a Bottle based on cfgData provided as a slice of bytes. cfgData should be the full bottle configuration as JSON. if it is not then you ust call btl.invalidateConfiguration() after calling Configure().
func (*Bottle) ConfigureFromFile ¶
ConfigureFromFile reads bottle configuration from the filename provided. This is the entry.yaml file containing metadata, but NOT including part data. For a complete bottle, the parts.json file should be loaded as well (such as with WithLocalPartFile(partFileName)(btl) ).
func (*Bottle) ConstructManifest ¶
ConstructManifest creates a ManifestHandler that corresponds to the data within a bottle, including configuration, part descriptors (layers), and annotations. This is a representation from an oci level, so part descriptors are at the oci layer level (archived/compressed) and not at the bottle level. The manifest handler that is stored within the bottle.
func (*Bottle) DeprecateBottleID ¶
func (btl *Bottle) DeprecateBottleID(bottleID digest.Digest)
DeprecateBottleID adds given bottleID to the bottle's deprecates slice.
func (*Bottle) GetBottleID ¶
func (btl *Bottle) GetBottleID() digest.Digest
GetBottleID returns a digest for the bottle configuration.
func (*Bottle) GetBottleManifest ¶
GetBottleManifest returns a digest for the bottle configuration.
func (*Bottle) GetCache ¶
func (btl *Bottle) GetCache() orascontent.GraphStorage
GetCache returns a oras content.GraphStorage interface for working with local cache data.
func (*Bottle) GetConfigPath ¶
GetConfigPath returns a path to the bottle's OCI config, i.e. '.config.json'. To get the path for the configuration in entry.yaml use EntryFile().
func (*Bottle) GetConfiguration ¶
GetConfiguration returns a byte slice containing json formatted configuration data for the bottle.
func (*Bottle) GetManifestAnnotations ¶
GetManifestAnnotations returns the expiration time of a bottle that is set during bottle push Needed to comply with the LocalData interface.
func (*Bottle) GetManifestArtifactType ¶
GetManifestArtifactType returns the artifact type for a bottle. Currently, this is a constant string based on the schema bottle media type.
func (*Bottle) GetManifestPath ¶
GetManifestPath returns a path to the bottle's OCI manifest, i.e. '.manifest.json'.
func (*Bottle) GetPartByLayerDescriptor ¶
func (btl *Bottle) GetPartByLayerDescriptor(descriptor ocispec.Descriptor) PartInfo
GetPartByLayerDescriptor returns a PartInfo for a part based on a descriptor from a manifest, matching by digest.
func (*Bottle) GetPartByName ¶
GetPartByName returns a single FileInfo matching the provided name.
func (*Bottle) GetPartStatus ¶
func (btl *Bottle) GetPartStatus(ctx context.Context, search PartTrack) PartStatus
GetPartStatus looks for an existing file entry based on the search file entry information, and returns a status bitfield.
func (*Bottle) GetParts ¶
GetParts returns a slice of PartTrack structures presented as a slice of FileInfo interfaces.
func (*Bottle) LoadLocalLabels ¶
LoadLocalLabels loads labels files.
func (*Bottle) NativePath ¶
NativePath converts the bottle relative UNIX path to a host native path This is the inverse of partName(). e.g., nativePath(partName("/foo/bar")) == "/foo/bar".
func (*Bottle) PartDescriptors ¶
func (btl *Bottle) PartDescriptors() ([]ocispec.Descriptor, error)
PartDescriptors generates a list of oci descriptors for bottle parts, which correspond to parts as they are represented in a manifest.
func (*Bottle) RemoveAnnotation ¶
RemoveAnnotation removes the annotation associated with the input key. Returns an error if the key is not found in annotation map of bottle schema.
func (*Bottle) RemoveArtifact ¶
RemoveArtifact removes a public artifact from the bottle definition. It looks for the provided path in the public artifact's definition. If the specified path is not found, then an error is returned.
func (*Bottle) RemoveAuthorInfo ¶
RemoveAuthorInfo removes author information from the bottle's definition using author's name as a key. If name is not found, then an error is returned.
func (*Bottle) RemoveLabel ¶
RemoveLabel removes the label associated with the input key. Returns an error if the key is not found in labels map of bottle schema.
func (*Bottle) RemoveMetricInfo ¶
RemoveMetricInfo removes the metric with specified name from the bottle. If the metric is not found, then an error is returned to the caller.
func (*Bottle) RemovePartLabel ¶
RemovePartLabel removes a label from a part using the provided key.
func (*Bottle) RemovePartMetadata ¶
RemovePartMetadata removes a file record from a Bottle files list.
func (*Bottle) RemoveSourceInfo ¶
RemoveSourceInfo removes a source from the bottle's list of sources if the name is not found, then we return an error to the caller.
func (*Bottle) Save ¶
Save writes the bottle information to the local disk based on internal path information, in yaml format. if saveJson is true a json version of the data is saved as well.
func (*Bottle) ScratchPath ¶
ScratchPath returns the directory (guaranteed to exist) or cache local temporary files.
func (*Bottle) SetDescription ¶
SetDescription add or update the description of a bottle.
func (*Bottle) SetManifest ¶
func (btl *Bottle) SetManifest(manifest oci.ManifestHandler)
SetManifest sets a bottle's manifest to the provided ManifestHandler.
func (*Bottle) SetRawManifest ¶
SetRawManifest retains the provided raw manifest data in the bottle for future reference.
func (*Bottle) Touch ¶
func (btl *Bottle) Touch()
Touch marks all file entries with the file system reported time if the part exists and can be accessed. The modtime information is only updated if the existing modified time is earlier than the time reported by the filesystem.
func (*Bottle) UpdatePartMetadata ¶
func (btl *Bottle) UpdatePartMetadata(name string, contentSize int64, contentDigest digest.Digest, lbls map[string]string, layerSize int64, layerDigest digest.Digest, mediaType string, modtime *time.Time, )
UpdatePartMetadata changes the metadata for the part identified by name.
func (*Bottle) VerifyBottleID ¶
VerifyBottleID verifies that the bottle ID matched what is passed in. The algorithm in the matchBottleID is used to compute the digest of the bottle config.
type Options ¶
type Options struct { // WantDetails enables directory tree walking for gathering files changed within directories WantDetails bool // Visitor is a delegate for processing individual file infos with status indicators, set to null to perform a default Display action Visitor Visitor }
Options define a set of options for processing file statuses.
type PartInfo ¶
type PartInfo interface { // GetName returns a file name GetName() string // GetContentSize returns the size of a file in the bottle config (uncompressed, unarchived form) GetContentSize() int64 // GetContentDigest returns the digest of a file as it exists in uncompressed/unarchived state, and is the digest // referened in bottle config GetContentDigest() digest.Digest // GetLabels returns a map of label keys to values associated with a file GetLabels() labels.Set // GetLayerSize is the size of the layer (often compresses size) GetLayerSize() int64 // GetLayerDigest returns the digest of a file, as stored in cache or on the server. This can be the compressed and/or // archived form of the file, and in OCI terms is the LayerDigest GetLayerDigest() digest.Digest // GetMediaType returns the content media type string for a file GetMediaType() string // GetModTime returns the last known modified time of a file, and can be used to determine if a file on disk has // been modified since the last bottle operation GetModTime() time.Time }
PartInfo is an interface for oci file entry data retrieval.
type PartSelectorFunc ¶
PartSelectorFunc is a function that returns true if the part should be included in the download.
type PartSelectorOptions ¶
type PartSelectorOptions struct { Empty bool // Only pull metadata from the bottle Labels []string // Label selectors to apply Names []string // Names of parts to retrieve Artifacts []string // Filter by public artifact type }
PartSelectorOptions are options for creating a PartSelector.
func (*PartSelectorOptions) New ¶
func (opts *PartSelectorOptions) New(ctx context.Context) (PartSelectorFunc, error)
New creates a new PartSelectorFunc from the options.
type PartStatus ¶
type PartStatus uint8
PartStatus is a bitmask for file status flags.
const ( // StatusExists indicates a file that is tracked. StatusExists PartStatus = 1 << iota // StatusCached indicates a file that exists in the cache based on the // digest stored in the Bottle. StatusCached // StatusChanged indicates a file that has been modified more recently // than the entry known last update. StatusChanged // StatusDigestMatch indicates a digest match. StatusDigestMatch // StatusNew indicates a discovered file that is currently untracked. StatusNew // StatusDeleted indicates tracked file that is no longer discovered. StatusDeleted // StatusVirtual indicates tracked file that is not stored locally, e.g. excluded with a selector on pull. StatusVirtual )
type PartTrack ¶
type PartTrack struct { cfgdef.Part LayerSize int64 `json:"layerSize"` LayerDigest digest.Digest `json:"layerDigest"` MediaType string `json:"mediaType"` Modified time.Time `json:"modified"` }
PartTrack is a superset of the bottle definition part entry, and provides additional fields for tracking information and changes to parts. PartTrack structures implement the oci.FileInfo interface for inspecting part information.
func (*PartTrack) GetContentDigest ¶
func (p *PartTrack) GetContentDigest() digest.Digest
GetContentDigest returns the digest of the content (tar file, uncompressed) of the part implements oci.FileInfo interface.
func (*PartTrack) GetContentSize ¶
GetContentSize for PartTrack returns the size from the part track's part definition. This size is the original part size.
func (*PartTrack) GetLayerDigest ¶
func (p *PartTrack) GetLayerDigest() digest.Digest
GetLayerDigest for PartEntry implements storage.FileInfo interface, returning the digest for the part as represented by a layer when transformed to the part format.
func (*PartTrack) GetLayerSize ¶
GetLayerSize returns the size of the layer (compresses size).
func (*PartTrack) GetMediaType ¶
GetMediaType for PartTrack implements the GetFormat portion of the oci.FileInfo interface, returning the file entry format. This format is the "network format" for the part, which is a potentially tarred/compressed/encrypted manifestation of the part, and not the on-disk format of the part files.
func (*PartTrack) GetModTime ¶
GetModTime for PartTrack implements GetModified portion of the oci.FileInfo interface, returning the modified time for a part.
func (*PartTrack) SetLayerDigest ¶
func (p *PartTrack) SetLayerDigest(dgst digest.Digest)
SetLayerDigest sets a layer digest based on string format for a part.
func (*PartTrack) SetLayerSize ¶
SetLayerSize sets the layer size information for a part.
func (*PartTrack) SetMediaType ¶
SetMediaType sets the media type string for a part.
func (*PartTrack) SetModTime ¶
SetModTime sets modified time information for a part.
type SaveOptions ¶
SaveOptions is a structure for supplying options to the SaveUpdatesToSet function. By default, all options are "on", eg, the options to disable functions are all false.
type VirtRecord ¶
type VirtRecord struct { LayerID digest.Digest `json:"layer-id"` ContentID digest.Digest `json:"content-id"` }
A VirtRecord is a structure for tracking data for an individual virtual part, containing LayerID, ContentID, and a Location reference where the Layer can be found or retrieved. Content and Layer IDs are stored in digest format; with the algorithm included.
type VirtualParts ¶
type VirtualParts struct { VirtRecords []VirtRecord `json:"virt-records"` // contains filtered or unexported fields }
VirtualParts represents a set of local bottle part metadata that tracks parts that are not stored in a local copy of a bottle. Virtual parts are added to this collection when a pull uses a selector that excludes parts. Each virtual part is identified by a content ID, layer ID, and a reference where the bottle can be retrieved.
func NewVirtualPartTracker ¶
func NewVirtualPartTracker(basePath string) *VirtualParts
NewVirtualPartTracker initializes a VirtualParts object and loads any existing data from disk.
func (*VirtualParts) Add ¶
func (vp *VirtualParts) Add(layerID digest.Digest, contentID digest.Digest)
Add adds a layer/content and location reference for a layer to the collection.
func (*VirtualParts) HasContent ¶
func (vp *VirtualParts) HasContent(digest digest.Digest) bool
HasContent returns true if the virtual parts collection contains the specified content digest.
func (*VirtualParts) HasLayer ¶
func (vp *VirtualParts) HasLayer(digest digest.Digest) bool
HasLayer returns true if the virtual parts collection contains the specified layer digest.
func (*VirtualParts) Load ¶
func (vp *VirtualParts) Load() error
Load loads virtual part tracking data from disk.
func (*VirtualParts) Save ¶
func (vp *VirtualParts) Save() error
Save writes virtual file data to disk,.
type Visitor ¶
type Visitor func(PartInfo, PartStatus) (bool, error)
Visitor is a function delegate for performing an action based on a provided file info and status indicator return true to halt processing, or false to continue.
func PrepareUpdatedParts ¶
PrepareUpdatedParts performs bottle part processing as a delegate when scanning for changed parts. The bottle information is updated with the changed data, preserving existing data where possible. Mostly, this involves removing file entries, resetting file entries (removing size/digest to trigger recalc), and adding file entries.