Documentation
¶
Overview ¶
Package port declares the artifacts module's store ports: repositories, items, the blob and replica indexes, the trash can, the package index, builds, the remote cache, Git LFS locks, Bower registrations, upload digests and archived items, the values their calls take and return, the checks every store applies before it writes, and Store, every store the module owns.
Role ¶
artifacts module, core layer, driven store ports. The module's adapters (adapters/sql and adapters/inmem) implement every port here, and each satisfies Store; the metadata store's SQL and in-memory stores delegate every artifacts accessor to them and satisfy Store too. The ports take and return the module's core/model values, repository configurations (artifacts/api/repo), AQL queries and hits (core/aql), kernel.Page, the platform's blob row and the mirror's replica rows.
Inputs ¶
- Repository configurations, items with their properties and statistics, blob and replica rows, trash entries, packages and versions, build runs with their promotions and retention, remote cache keys, tokens and entries, Git LFS locks, Bower registrations, an upload's digests and archived items, to store; keys, paths, ids and checksums to look up.
- A RepoFilter, GitLFSLockFilter, ArchivedFilter or the mirror's ReplicaFilter, with a kernel.Page, to narrow a listing; an AQL query with its options to search items or builds.
- The context of the caller's transaction, which every call joins.
Outputs ¶
- RepoStore with RepoFilter, and its Page with RepoListing, RepoSet, RepoSummary and RepoPage: one window of the repository list, its filters and the caller's visibility applied in the store (#1408), or the window after a key (RepoListing.After) for a caller that streams the whole list (#1409); ItemStore with Download, DeleteResult and RepoUsage, whose DescendantsByFullPath walks a folder's descendants in the storage file list's order, so that list is written a page at a time (#1409); BlobIndex with the sentinel ErrDeleting; ReplicaIndex; TrashStore, whose BelowByPath walks the trash can's tree in path order, so its storage views are written a page at a time (#1409); and PackageStore, which embeds PackageVersionNames: a package's version names alone, in Versions' order, which the Puppet, Ansible and Chef lists count and order before they read their page's records for a caller who may read only some paths (#1404), and their count and a page of them for one who may read every path (CountVersions, VersionNamesAt); and PackagePages, with PackageRange, NuGetShown, VersionTally, ReleaseName and CandidatesAt: a repository's packages with a version, and their versions, counted and paged by name, tallied and listed by release, which npm's and NuGet's searches, NuGet's V2 feeds and the Chef and Puppet lists read for such a caller (#1425, #1426).
- DockerPageStore, the item store's reader of a registry repository's image layout a page at a time (ItemStore.DockerPages), with DockerFolderQuery, DockerImageQuery, DockerImageManifest and DockerFold.
- BuildStore with NormaliseBuild, whose DependencyPage is one keyset page of FindDependencies, which the dependency search streams (#1409); BowerRegistrationStore; UploadDigestStore, the SHA-1 and MD5 an upload computed, by the content's SHA-256 (#1581); GitLFSLockStore with GitLFSLockFilter; and ArchivedItemStore with ArchivedFilter.
- CleanProperties, CheckPropertyKeys and CheckBuildPropertyKeys, how every store keeps and checks properties.
- RemoteCacheStore, with NewRemoteSource, RemoteConfigChanged, RemoteSourceConfig, RemotePolicyChanged, RemoteCacheID, ValidateRemoteKey, RemotePathMatches and ValidateRemoteEntry.
- Store: tx.Runner and the 14 accessors Repos, RemoteCache, Items, Blobs, Replicas, Trash, Packages, GitLFSLocks, BowerRegistrations, UploadDigests, Builds, ArchivedItems, ColdBlobs and ColdReplicas.
Invariants ¶
- Every store joins the caller's unit of work: a call made with a context inside Tx is part of that transaction, and is rolled back with it.
- ColdBlobs and ColdReplicas index the cold tier (the cold_blobs and cold_blob_replicas tables) with the same code as Blobs and Replicas, so they return the same port types (decision 0024).
- BlobIndex and ReplicaIndex satisfy the mirror's own index ports, because they take and return the mirror's replica rows and the platform's blob row rather than copies of them (decision 0028).
- Errors are the kernel's sentinels, wrapped, and ErrDeleting for a blob that garbage collection is removing: a deleting row refuses references, so no deploy references content that is about to go (decision 0010).
- Every store checks property keys before it writes and keeps values as CleanProperties returns them, so a property write stores every key or none, whichever route it came by.
References ¶
- Decision 0004: docs/research/decisions/0004-storage-sql-metadata-and-blobs.md.
- Decision 0007: docs/research/decisions/0007-remote-repositories.md (the remote cache and its fences).
- Decision 0010: docs/research/decisions/0010-retention-trash-and-gc.md (the trash can and blob garbage collection).
- Decision 0012: docs/research/decisions/0012-search-and-aql.md.
- Decision 0014: docs/research/decisions/0014-build-info.md.
- Decision 0018: docs/research/decisions/0018-package-index.md.
- Decision 0024: docs/research/decisions/0024-cold-storage-tier.md.
- Decision 0028: docs/research/decisions/0028-blob-mirroring.md.
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence" and "Names the migration introduces", which lists Store).
- Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 189 to 192 (the artifacts module's core/port/store.go), lines 577 and 578 (each module owns its store ports), line 601 (the artifacts port) and line 1055 (the metadata store split into each module's core/port/store.go).
- Plan: docs/implementation/plan.md#p2-stores, #p5-full-aql-searches-build-info, #p9-remote-repositories, #p9b-newly-identified-artifactory-formats and #p9d-modular-monolith-migration, epic STO (https://github.com/weaveplatform/artifactweave/issues/939).
- https://github.com/weaveplatform/artifactweave/issues/1055
- https://github.com/weaveplatform/artifactweave/issues/1062
Status ¶
Implemented P2: RepoStore, ItemStore, BlobIndex, TrashStore and PackageStore, with the metadata store's in-memory, SQLite and PostgreSQL stores (pull request 3), and ReplicaIndex with the blob mirror (pull request 30). Later phases added BuildStore (pull request 193), the property key checks (pull request 348), RemoteCacheStore (pull request 646), GitLFSLockStore (pull request 849) and BowerRegistrationStore (pull request 912). Moved here in P9d, which added ArchivedItemStore and Store. DockerPageStore pages the registry's tags lists and catalogs (#1402). RepoStore.Page pages Get Repositories in the store (#1408). UploadDigestStore keeps a Hugging Face LFS upload's SHA-1 and MD5 for its commit (#1581).
Testing ¶
The package has no tests of its own. The module's adapters declare at compile time that their stores satisfy Store (adapters/inmem/store.go and adapters/sql/store.go), and the metadata store's in-memory and SQL stores are checked against it beside the other modules' ports (internal/app/adapters/inmem/inmem_test.go and internal/app/adapters/sql/store_test.go). The module's contract suite, adapters/storetest, runs every port on the module's adapters (adapters/inmem's TestUnitContract, and adapters/sql's TestAccContract on SQLite in memory and in a file) and on the metadata store's in-memory, SQLite and PostgreSQL backends from inside its contract suite.
Index ¶
- Constants
- Variables
- func CheckBuildPropertyKeys(b model.Build) error
- func CheckBuildReport(r model.BuildReport) error
- func CheckPropertyKeys(props model.Properties) error
- func CleanProperties(props model.Properties, limit int) model.Properties
- func DockerFold(s string) string
- func NewRemoteSource(key string) model.SourceIdentity
- func NormaliseBuild(b model.Build) model.Build
- func RemoteCacheID(k model.RemoteCacheKey) string
- func RemoteConfigChanged(a, b repo.Config) bool
- func RemotePathMatches(path, prefix string) bool
- func RemotePolicyChanged(a, b repo.Config) bool
- func RemoteSourceConfig(c repo.Config) repo.Config
- func SearchFold(s string) string
- func SearchMayMatch(name string, metadata []byte, runs [][]string) bool
- func SearchPrefixEnd(prefix string) (end string, ok bool)
- func SearchRuns(terms []string) [][]string
- func ValidateRemoteEntry(e model.RemoteCacheEntry) error
- func ValidateRemoteKey(k model.RemoteCacheKey) error
- type ArchivedFilter
- type ArchivedItemStore
- type BlobIndex
- type BowerRegistrationStore
- type BuildStore
- type DeleteResult
- type DockerFolderQuery
- type DockerImageManifest
- type DockerImageQuery
- type DockerPageStore
- type Download
- type GitLFSLockFilter
- type GitLFSLockStore
- type ItemStore
- type NpmSearch
- type NuGetSearch
- type NuGetShown
- type PackagePages
- type PackageRange
- type PackageStore
- type PackageVersionNames
- type ReleaseName
- type RemoteCacheStore
- type ReplicaIndex
- type RepoFilter
- type RepoListing
- type RepoPage
- type RepoSet
- type RepoStore
- type RepoSummary
- type RepoUsage
- type SearchCandidate
- type Store
- type TrashStore
- type UploadDigestStore
- type VersionTally
Constants ¶
const ( NuGetPathKey = "path" NuGetVersionKey = "version" NuGetSemVer2Key = "semver2" )
The keys of a NuGet version's stored metadata that NuGetShown reads. They must match nugetfmt.Metadata's JSON names, which the nuget package's tests check.
const ( // SearchEscape is the JSON escape that can spell any character, // including the ASCII a run looks for, so a version whose metadata // holds one is a candidate whatever its text. SearchEscape = `\u` )
The candidates of a text search are the packages with a version for which, for every term with SearchRuns, either each run appears in SearchFold of the package's name, or each appears in SearchFold of the version's stored metadata, or the metadata is empty or holds SearchEscape. Every package whose name or decoded metadata text holds each term after strings.ToLower is one, so a store narrows a search without changing what it lists; it may return packages that match nothing, and the handler, which matches each package by the newest version its caller may read, decides.
The store cannot match exactly. Only the versions the caller may read count, and the access module decides that per path, in Go, from permission patterns that SQL cannot evaluate; and the text a search matches is decoded from JSON and lower-cased by Go, Unicode and all, where SQLite's lower() folds ASCII alone. What it can test the same way on SQLite, PostgreSQL and in memory is the printable ASCII the term holds, against the stored JSON as written.
Variables ¶
var ErrDeleting = errors.New("store: blob is being deleted")
ErrDeleting reports a blob whose content garbage collection is removing: it cannot be referenced until the removal has finished.
var SearchFoldPairs = [][2]string{{"İ", "i"}, {"K", "k"}}
SearchFoldPairs are the runes SearchFold replaces before it lower-cases ASCII, each with its replacement, which the SQL stores replace the same way.
Functions ¶
func CheckBuildPropertyKeys ¶
CheckBuildPropertyKeys is CheckPropertyKeys over b's build and module properties.
func CheckBuildReport ¶
func CheckBuildReport(r model.BuildReport) error
CheckBuildReport refuses a report every backend refuses: one without an action, or whose expiry is not after its creation at the stores' microsecond precision, which PruneReports would remove at once.
func CheckPropertyKeys ¶
func CheckPropertyKeys(props model.Properties) error
CheckPropertyKeys returns kernel.ErrInvalid, wrapping model.ErrPropertyKeyTooLong, when a key of props is longer than model.PropertyKeyMax. Every store checks before it writes, so a property write either stores every key or none, whichever route it came by.
func CleanProperties ¶
func CleanProperties(props model.Properties, limit int) model.Properties
CleanProperties is how the stores keep properties, one row per value: keys without values dropped, each value cut to limit (model.TruncatePropertyValue), and the values sorted and unique, so two values that differ only past the limit become one.
func DockerFold ¶
DockerFold is the folding DockerPageStore orders folder names by: A to Z become a to z and every other byte stays, as lower() folds on SQLite and, under COLLATE "C", on PostgreSQL. A listing continued after a folder the store returned passes this fold of it, never another: a fold that moved a name elsewhere in the store's order would repeat or skip folders.
func NewRemoteSource ¶
func NewRemoteSource(key string) model.SourceIdentity
NewRemoteSource creates a durable identity, never a configuration hash.
func NormaliseBuild ¶
NormaliseBuild is what every backend stores and returns for b: Normalise, with build and module properties cleaned (CleanProperties) to model.BuildPropertyValueMax.
func RemoteCacheID ¶
func RemoteCacheID(k model.RemoteCacheKey) string
RemoteCacheID bounds a SQL key independently of path length. The actual key is stored and compared, so a hash collision cannot reuse a representation.
func RemoteConfigChanged ¶
RemoteConfigChanged reports source identity changes, excluding policy-only settings. Policy changes still fence in-flight writes via PolicyRevision.
func RemotePathMatches ¶
RemotePathMatches includes a prefix itself and its descendants, not siblings.
func RemotePolicyChanged ¶
RemotePolicyChanged reports a noncosmetic configuration change. Tokens must be re-authorized after these edits even when content retains its identity.
func RemoteSourceConfig ¶
RemoteSourceConfig removes settings that govern use of cached bytes rather than their upstream identity. Credential resolvers can use this projection.
func SearchFold ¶
SearchFold is s as a store compares it with a run: ASCII letters lower case, and U+0130 and U+212A, the two runes strings.ToLower turns into ASCII ("i" and "k"), replaced by what it makes of them. Every other rune is left as it is, as SQLite's lower() leaves it.
func SearchMayMatch ¶
SearchMayMatch reports whether a version of the package called name, whose stored metadata is metadata, makes the package a candidate for a search whose runs (SearchRuns) are runs.
func SearchPrefixEnd ¶
SearchPrefixEnd is the least string that sorts, in byte order, after every string that starts with prefix, a valid UTF-8 string: prefix with its last rune that can grow by one grown, and what follows it dropped. UTF-8's byte order is its code points' order, so the names that start with prefix are those from prefix up to it. ok is false when no rune can grow, and nothing sorts after them.
func SearchRuns ¶
SearchRuns returns, for each term, the runs of it a store looks for: its longest stretches of printable ASCII other than `"`, `\` and `/`, which JSON may write as escapes (`\"`, `\\`, `\/`). A term without one, all non-ASCII say, narrows nothing and is left out.
func ValidateRemoteEntry ¶
func ValidateRemoteEntry(e model.RemoteCacheEntry) error
ValidateRemoteEntry refuses impossible body references and unknown kinds.
func ValidateRemoteKey ¶
func ValidateRemoteKey(k model.RemoteCacheKey) error
ValidateRemoteKey requires canonical paths and non-secret bounded variants.
Types ¶
type ArchivedFilter ¶
ArchivedFilter narrows archived item listings.
type ArchivedItemStore ¶
type ArchivedItemStore interface {
// AddItem stores an archived item and returns it with its assigned ID;
// kernel.ErrInvalid when the item's full path does not split
// (kernel.SplitItemPath).
AddItem(ctx context.Context, a model.ArchivedItem) (model.ArchivedItem, error)
// Item returns the archived item with id.
Item(ctx context.Context, id int64) (model.ArchivedItem, error)
// FindItems returns the archived copies of an original repository and
// full path, newest first by ID; kernel.ErrInvalid for a path that does not
// split.
FindItems(ctx context.Context, repoKey, fullPath string) ([]model.ArchivedItem, error)
// Items returns matching archived items ordered by ID; a zero
// ExecutionID matches every execution.
Items(
ctx context.Context,
f ArchivedFilter,
p kernel.Page,
) ([]model.ArchivedItem, string, error)
// DeleteItem removes an archived item.
DeleteItem(ctx context.Context, id int64) error
// ExpiredItems returns items whose ExpiresAt is set and before t,
// oldest first, at most limit (kernel.DefaultLimit when zero).
ExpiredItems(ctx context.Context, before time.Time, limit int) ([]model.ArchivedItem, error)
}
ArchivedItemStore persists the records archived items leave behind (decision 0024): each item's full metadata, so a restore recreates it and AQL over archives can search it. The records belong to artifacts, while the archive policies and executions that made them are retention's (ArchiveStore).
type BlobIndex ¶
type BlobIndex interface {
// Ref adds n references to b and returns the row as updated. An absent row
// is created live; a tombstone is revived, keeping Deleted. ErrDeleting
// while the row is deleting; kernel.ErrConflict when the stored size or
// checksums differ from b's, which means two different contents claim one
// sha256.
Ref(ctx context.Context, b blob.Blob, n int64) (blob.Blob, error)
// Unref removes n references, never going below zero, and returns the
// row as updated.
Unref(ctx context.Context, sha256 string, n int64) (blob.Blob, error)
// Get returns the row for sha256, in whatever state.
Get(ctx context.Context, sha256 string) (blob.Blob, error)
// Find returns the live blob matching the strongest digest set in c
// (sha256, then sha1, then md5). SHA512 is not a lookup key, as for
// FindByChecksum.
Find(ctx context.Context, c kernel.Checksums) (blob.Blob, error)
// Unreferenced lists live blobs with no references, ordered by sha256.
Unreferenced(ctx context.Context, p kernel.Page) ([]blob.Blob, string, error)
// MarkDeleting starts removing b's content: an unreferenced live row or a
// tombstone becomes deleting at at, and content the index has no row for
// gets a deleting row from b. A row already deleting is returned as it
// is. kernel.ErrConflict while the row is referenced.
MarkDeleting(ctx context.Context, b blob.Blob, at time.Time) (blob.Blob, error)
// FinishDelete turns a deleting row into a tombstone deleted at at, once
// its content is gone. A tombstone is left as it is; kernel.ErrConflict for
// a live row, kernel.ErrNotFound when there is no row.
FinishDelete(ctx context.Context, sha256 string, at time.Time) error
// Deleting lists the rows being deleted, ordered by sha256, so a pass
// can finish what a crashed one started.
Deleting(ctx context.Context, p kernel.Page) ([]blob.Blob, string, error)
// Prune drops tombstones deleted before before and clears Deleted on
// live rows deleted before then, returning how many rows changed.
Prune(ctx context.Context, before time.Time) (int64, error)
// Totals returns the number of live blobs and their combined size.
Totals(ctx context.Context) (count, bytes int64, err error)
}
BlobIndex is the content-addressed blob index (the blobs table, and the cold_blobs table for the archive tier). Rows are keyed by sha256 and reference-counted; garbage collection deletes blobs whose count reached zero.
Garbage collection removes a blob in three steps (decision 0010): MarkDeleting, then the content delete, then FinishDelete. A deleting row refuses references, and the tombstone FinishDelete leaves records when the content went, so a deploy that wrote the same content just before it was removed finds out and never references missing content.
type BowerRegistrationStore ¶
type BowerRegistrationStore interface {
Create(context.Context, model.BowerRegistration) error
Get(context.Context, string, string) (model.BowerRegistration, error)
List(context.Context, string, kernel.Page) ([]model.BowerRegistration, string, error)
}
BowerRegistrationStore persists immutable name-to-Git mappings. Create is exclusive on (repository, name); repository deletion removes registrations.
type BuildStore ¶
type BuildStore interface {
// Put stores a new run with its modules and returns it with its
// assigned ID. kernel.ErrConflict when (project, name, number, started)
// exists; kernel.ErrInvalid when the name or number is empty or started is
// zero.
Put(ctx context.Context, b model.Build) (model.Build, error)
// Replace replaces the content of run b.ID: its URL, modification stamp,
// properties, modules and document. The identity (project, name, number,
// started) and Created stay as stored. kernel.ErrNotFound when the run does
// not exist.
Replace(ctx context.Context, b model.Build) error
// Get returns a run with its modules. A zero started selects the
// latest-started run of that number. kernel.ErrNotFound when there is none.
Get(
ctx context.Context,
projectKey, name, number string,
started time.Time,
) (model.Build, error)
// GetForUpdate is Get with a row lock held until the enclosing Tx ends.
// It requires a transaction context; use it before read-modify-write.
GetForUpdate(
ctx context.Context,
projectKey, name, number string,
started time.Time,
) (model.Build, error)
// ByID returns the run with id, with its modules.
ByID(ctx context.Context, id int64) (model.Build, error)
// ByIDForUpdate locks the identified run before loading its content.
// It requires an enclosing Tx, like GetForUpdate.
ByIDForUpdate(ctx context.Context, id int64) (model.Build, error)
// Latest returns the latest-started run of a name, with its modules.
// kernel.ErrNotFound when the name has no runs.
Latest(ctx context.Context, projectKey, name string) (model.Build, error)
// Runs lists a name's runs, newest first by (started, ID). A name with
// no runs lists nothing.
Runs(
ctx context.Context,
projectKey, name string,
p kernel.Page,
) ([]model.BuildRun, string, error)
// Names lists a project's build names ordered by name, each with the
// start of its latest run.
Names(ctx context.Context, projectKey string, p kernel.Page) ([]model.BuildName, string, error)
// DeleteNumbers deletes one run for each occurrence of a number in
// numbers, the earliest-started of that number's remaining runs first,
// and returns the deleted runs in deletion order. An occurrence with no
// run left is skipped. This is what `jf rt bp --overwrite` expects: it
// sends a number once per existing run.
DeleteNumbers(
ctx context.Context,
projectKey, name string,
numbers []string,
) ([]model.BuildRun, error)
// DeleteAll deletes every run of a name and its retention, and returns
// the deleted runs oldest first.
DeleteAll(ctx context.Context, projectKey, name string) ([]model.BuildRun, error)
// Rename moves every run of a name, and its retention, to another name. A
// retention left on to, which has no runs, is replaced by from's or removed
// when from has none. kernel.ErrNotFound when from has no runs;
// kernel.ErrConflict when to has runs. Renaming a name to itself does
// nothing.
Rename(ctx context.Context, projectKey, from, to string) error
// AddPromotion records a promotion of run p.BuildID and returns it
// with its assigned ID. kernel.ErrNotFound when the run does not exist.
AddPromotion(ctx context.Context, p model.BuildPromotion) (model.BuildPromotion, error)
// Promotions returns a run's promotions oldest first by (created, ID).
// kernel.ErrNotFound when the run does not exist.
Promotions(ctx context.Context, buildID int64) ([]model.BuildPromotion, error)
// PutReport stores a keyed build action's report and returns its
// assigned, positive ID. kernel.ErrInvalid when the action is empty or
// Expires is not after Created.
PutReport(ctx context.Context, r model.BuildReport) (int64, error)
// ReportForUpdate locks and returns the report with id, expired or
// not. It requires an enclosing Tx, like GetForUpdate.
// kernel.ErrNotFound when there is none.
ReportForUpdate(ctx context.Context, id int64) (model.BuildReport, error)
// PruneReports removes at most limit reports whose Expires is at or
// before now, oldest expiry first, and returns how many it removed.
// A limit outside 1..kernel.MaxLimit is kernel.ErrInvalid.
PruneReports(ctx context.Context, now time.Time, limit int) (int64, error)
// FindArtifacts returns the build artifacts whose checksums match every
// non-empty field of c, across all projects, ordered by run ID, then
// module and file position. kernel.ErrInvalid when c has no checksum.
FindArtifacts(ctx context.Context, c kernel.Checksums) ([]model.BuildFileRef, error)
// FindDependencies is FindArtifacts for dependencies.
FindDependencies(ctx context.Context, c kernel.Checksums) ([]model.BuildFileRef, error)
// DependencyPage is one keyset page of FindDependencies, in its order,
// for a search that writes its answer as it reads it (#1409).
DependencyPage(
ctx context.Context,
c kernel.Checksums,
p kernel.Page,
) ([]model.BuildFileRef, string, error)
// Search runs an AQL builds or build.promotions query (decision
// 0012): the matching runs, or promotions with their runs, in the
// order aql.SelectBuilds returns them. A hit's run carries its own
// columns only, not its properties, modules or document. Relation
// paths reach items by checksum. kernel.ErrInvalid for an items query.
Search(ctx context.Context, q *aql.Query, o aql.Options) ([]aql.BuildHit, error)
// PutRetention creates or replaces a build name's retention.
PutRetention(ctx context.Context, r model.BuildRetention) error
// Retention returns a build name's retention. kernel.ErrNotFound when none
// is set.
Retention(ctx context.Context, projectKey, name string) (model.BuildRetention, error)
}
BuildStore persists build-info runs (decision 0014): one record per run, keyed by (project, name, number, started), with the document as published and its modules, properties, artifacts and dependencies as rows for the AQL build domains and the checksum searches. A project key of "" is the default project.
The store keeps the document itself and serves reads from it. Writing the copy of the document as an item (model.Build.DocumentItem) belongs to the build service, which holds the blob store: it puts the run and the item in one Tx, so a publish or a delete changes both or neither.
type DeleteResult ¶
DeleteResult summarises an ItemStore.Delete. BlobRefs counts, per sha256, the file references removed, which is what the caller passes to BlobIndex.Unref.
type DockerFolderQuery ¶
type DockerFolderQuery struct {
RepoKey string
Image string
// AfterFold and After continue a listing: a folder is listed when its
// folded name follows AfterFold, or equals it and the name's bytes follow
// After. The caller folds After itself, since its fold of a name a client
// sends need not be ASCII; both empty list every folder.
AfterFold, After string
Limit int
}
DockerFolderQuery selects the manifest folders of one image.
type DockerImageManifest ¶
DockerImageManifest is a stored manifest's image and the folder below the image that holds it.
type DockerImageQuery ¶
type DockerImageQuery struct {
RepoKey string
// After continues a listing at the images whose names' bytes follow it.
// Within keeps After's own manifests too, in the folders whose names'
// bytes follow AfterFolder (all of them when it is empty), so a listing
// can resume inside an image or start at one.
After string
Within bool
AfterFolder string
Limit int
}
DockerImageQuery selects the manifests of one repository's images.
type DockerPageStore ¶
type DockerPageStore interface {
// ManifestFolders returns the folders directly below q.Image that hold a
// stored manifest, each once, ordered by their folded names and then by
// their bytes: the order of the registry's tags lists. Only folders after
// the cursor are listed, at most q.Limit of them (all when it is not
// positive), so fewer than q.Limit means there are no more.
ManifestFolders(ctx context.Context, q DockerFolderQuery) ([]string, error)
// ImageManifests returns the image and folder of each stored manifest in
// a folder below an image (never one in a top-level folder), each pair
// once, ordered by the image's bytes and then the folder's: the order of
// the registry's catalogs, whose images are lower case. Only pairs after
// the cursor are listed, at most q.Limit (all when it is not positive).
ImageManifests(ctx context.Context, q DockerImageQuery) ([]DockerImageManifest, error)
}
DockerPageStore reads the image layout of a Docker, OCI or Helm OCI repository's local content (decision 0031) a page at a time, in the orders the registry's tags lists and catalogs answer in, so that a listing reads the page it serves rather than every manifest of the image or repository (#1402). It sees the stored manifests alone: files named manifest.json or list.manifest.json. Which of their folders are tags, and which images a client could pull, is the registry's to judge.
Folding is DockerFold. Every tag and every valid image name is ASCII, so for them it is the registry's own case folding (strings.ToLower).
type Download ¶
Download is one recorded download of an item. Remote marks a download served to another instance through a smart remote repository, which Artifactory counts separately along with where it went.
type GitLFSLockFilter ¶
type GitLFSLockFilter struct{ RepoKey, Path, ID string }
GitLFSLockFilter restricts a lock listing to one repository and optional exact path or ID. RepoKey is required.
type GitLFSLockStore ¶
type GitLFSLockStore interface {
Create(context.Context, model.GitLFSLock) error
Get(context.Context, string, string) (model.GitLFSLock, error)
List(context.Context, GitLFSLockFilter, kernel.Page) ([]model.GitLFSLock, string, error)
Delete(context.Context, string, string) (model.GitLFSLock, error)
}
GitLFSLockStore keeps active Git worktree locks separately from LFS objects. Create is exclusive on (repository, path); Delete returns the removed row.
type ItemStore ¶
type ItemStore interface {
// Create inserts an item only if its natural key is absent. A collision
// returns kernel.ErrConflict without changing the existing item. Path
// handling and assigned IDs are the same as Put.
Create(ctx context.Context, it model.Item) (model.Item, error)
// Put creates the item or replaces the one at the same natural key,
// keeping that item's ID, and returns it as stored. The store derives
// Path, Name and Depth from FullPath, so callers may set either Path and
// Name or a full path in Name; kernel.ErrInvalid when it does not split
// (kernel.SplitItemPath). Parent folders are not created.
Put(ctx context.Context, it model.Item) (model.Item, error)
// Get returns the item at fullPath.
Get(ctx context.Context, repoKey string, cached bool, fullPath string) (model.Item, error)
// GetByID returns the item with id.
GetByID(ctx context.Context, id int64) (model.Item, error)
// Children lists the items directly inside folder, ordered by name.
Children(
ctx context.Context, repoKey string, cached bool, folder string, p kernel.Page,
) ([]model.Item, string, error)
// Descendants lists every item below folder, ordered by (path, name).
Descendants(
ctx context.Context, repoKey string, cached bool, folder string, p kernel.Page,
) ([]model.Item, string, error)
// DescendantsByFullPath lists every item below folder, ordered by full
// path byte by byte: the order of the storage API's file list, which
// sorts its entries by their uri, so that list can be written a page at
// a time (#1409). Children's name order is the same order one level
// down.
DescendantsByFullPath(
ctx context.Context, repoKey string, cached bool, folder string, p kernel.Page,
) ([]model.Item, string, error)
// Delete removes the item at fullPath and, for a folder, everything below
// it, with their properties and statistics. A root path removes all of
// (repoKey, cached) but the root's record, which belongs to the repository
// rather than its content, and returns a zero result for an empty
// repository; any other path returns kernel.ErrNotFound when nothing is
// there.
Delete(ctx context.Context, repoKey string, cached bool, fullPath string) (DeleteResult, error)
// Root returns the record of the root of (repoKey, cached),
// kernel.ErrNotFound while it has none.
Root(ctx context.Context, repoKey string, cached bool) (model.Item, error)
// EnsureRoot returns the record of the root of (r.RepoKey, r.Cached),
// creating it as model.RootItem with r's times and actors when absent;
// kernel.ErrInvalid without a repository key.
EnsureRoot(ctx context.Context, r model.Item) (model.Item, error)
// DeleteRoot removes the record of the root of (repoKey, cached) with
// its properties, when the repository itself is removed. A root without
// a record is not an error.
DeleteRoot(ctx context.Context, repoKey string, cached bool) error
// FindByChecksum lists files whose actual checksum matches the
// strongest digest set in c (sha256, then sha1, then md5), ordered by
// ID. SHA512 is not a lookup key: whatever holds one holds the sha256.
FindByChecksum(
ctx context.Context,
c kernel.Checksums,
p kernel.Page,
) ([]model.Item, string, error)
// Usage returns content totals per repository and cache, ordered by
// (repository, cached).
Usage(ctx context.Context) ([]RepoUsage, error)
// Search runs an AQL items query: the matching items in the query's
// order (then by ID), after its offset and within its limit, or within
// o.Limit when it has none. Hits carry their properties only when the
// query includes them. Every backend returns the same rows in the same
// order as aql.Select.
Search(ctx context.Context, q *aql.Query, o aql.Options) ([]aql.Hit, error)
// DockerPages reads the image layout a page at a time (docker_page.go).
DockerPages() DockerPageStore
// Properties returns the item's properties (empty when it has none). This
// and the other property and statistics methods return kernel.ErrNotFound
// for a missing item. A key given with no values is not stored.
//
// SetProperties and PatchProperties take the time of the write, at. A write
// that changes the properties sets the item's PropertiesModified to at, or
// to zero when it leaves none; a write that changes nothing leaves it
// alone, as Artifactory 6.20 touches its node_meta_infos row only when
// PropertiesService.setProperties reports a change.
Properties(ctx context.Context, id int64) (model.Properties, error)
// SetProperties replaces all of the item's properties.
SetProperties(ctx context.Context, id int64, props model.Properties, at time.Time) error
// PatchProperties removes the keys in remove, then replaces the values of
// the keys in set (so a key in both ends with the set values), leaving
// other keys alone.
PatchProperties(
ctx context.Context, id int64, set model.Properties, remove []string, at time.Time,
) error
// Stats returns the item's statistics, zero when nothing was recorded.
Stats(ctx context.Context, id int64) (model.ItemStats, error)
// RecordDownload counts one download.
RecordDownload(ctx context.Context, id int64, d Download) error
// PutStats replaces the statistics, for import and federation sync.
PutStats(ctx context.Context, id int64, s model.ItemStats) error
}
ItemStore persists items in the canonical form of decision 0004, with their properties and download statistics. An item's natural key is (RepoKey, Cached, Path, Name); its ID is assigned by the store. Paths are repository-relative without a leading slash; "" and "." both name the repository root.
A repository root has a record (model.RootItem) once properties are set on it, so they are kept and found by item ID like any item's. Only Root, EnsureRoot, GetByID and Search return it; Get, Children, Descendants, FindByChecksum and Usage leave it out, as does the result of Delete.
type NpmSearch ¶
type NpmSearch struct {
RepoKey string
// Terms are the search's terms, lower case as strings.ToLower makes
// them. With none, every package with a version is a candidate.
Terms []string
}
NpmSearch is what npm search (GET /-/v1/search) asks the package index for (PackageStore.SearchNpm): the packages of RepoKey that Terms may match.
type NuGetSearch ¶
type NuGetSearch struct {
RepoKey string
// Terms are the search's terms, lower case as strings.ToLower makes
// them. With none, every package with a version is a candidate.
Terms []string
// Prefix, when not empty, keeps only the names that start with it,
// in bytes: an autocomplete's, and a feed of one id's versions, which
// starts at that id. No name holds a NUL byte, so a Prefix with one
// keeps none.
Prefix string
}
NuGetSearch is what NuGet's search, autocomplete and v2 feeds ask the package index for (PackageStore.SearchNuGet): the packages of RepoKey whose names start with Prefix that Terms may match, as npm_search.go defines a text search's candidates.
type NuGetShown ¶
type NuGetShown struct {
Prerelease, SemVer2 bool
}
NuGetShown is which versions a NuGet feed shows a caller who may read all of them (decision 0038), from each version's stored metadata, as nugetfmt.Metadata writes it: those whose .nupkg is stored (a non-empty NuGetPathKey), and of those the pre-releases (a hyphen in NuGetVersionKey) only with Prerelease, and the SemVer 2.0.0 versions (NuGetSemVer2Key true) only with SemVer2. A version without metadata has no .nupkg. A store reads the metadata as JSON, so one that is not fails the read, as the feed's own decoding fails on it.
type PackagePages ¶
type PackagePages interface {
// CountPackages returns how many packages of r have a version r
// admits.
CountPackages(ctx context.Context, r PackageRange) (int, error)
// PackagesAt returns the packages CountPackages counts that come at
// offset of limit by name, in byte order, as List orders them.
PackagesAt(ctx context.Context, r PackageRange, offset, limit int) ([]model.Package, error)
// CountRangeVersions returns how many versions of r's packages r
// admits: what a NuGet V2 feed of every version counts.
CountRangeVersions(ctx context.Context, r PackageRange) (int, error)
// RangeVersionsAt returns the versions CountRangeVersions counts at
// offset of limit in a list of them by package name and then, within a
// package, in Versions' order: a NuGet V2 feed's page.
RangeVersionsAt(ctx context.Context, r PackageRange, offset, limit int) ([]ReleaseName, error)
// Candidates returns packages, in their order, each with every one of
// its versions in Versions' order, in one read; a package with no
// version left, deleted since it was paged, is left out, as SearchNpm
// leaves it out.
Candidates(ctx context.Context, packages []model.Package) ([]SearchCandidate, error)
// TallyVersions counts, over the first limit packages of repoKey by
// name, those without a version included, how many there are, how
// many versions they hold and the most one of them holds: the caps a
// whole-repository list answers 503 over.
TallyVersions(ctx context.Context, repoKey string, limit int) (VersionTally, error)
// ReleasesAt returns the versions of repoKey's packages at offset of
// limit in a list of them by package name and then, within a package,
// from its highest OrderKey down: Puppet's whole-repository release
// list, newest first.
ReleasesAt(ctx context.Context, repoKey string, offset, limit int) ([]ReleaseName, error)
}
PackagePages counts and pages a repository's packages in the store, for the lists whose caller may read every path of the repository (accessapi.Decider.AllowsAll): npm and NuGet search, NuGet's autocomplete and V2 feeds, Chef's catalog and Puppet's whole-repository lists (#1425, #1426). Such a caller sees every package with a version, so the count and the page are exact in the store; a caller whose permissions name paths still has each version checked by the handler, over SearchNpm, SearchNuGet, List or VersionNames.
type PackageRange ¶
type PackageRange struct {
RepoKey string
// Prefix, when not empty, keeps only the names that start with it, in
// bytes, as NuGetSearch's Prefix does; a Prefix with a NUL byte keeps
// none.
Prefix string
// Shown, when set, admits only the versions a NuGet feed shows.
Shown *NuGetShown
}
PackageRange is the packages of RepoKey that PackagePages counts and pages: those whose names start with Prefix that have a version Shown admits, every version when Shown is nil.
type PackageStore ¶
type PackageStore interface {
// Ensure returns the package (p.RepoKey, p.Name), creating it from p
// when absent.
Ensure(ctx context.Context, p model.Package) (model.Package, error)
// Get returns the package with id.
Get(ctx context.Context, id int64) (model.Package, error)
// Find returns the package called name in repoKey.
Find(ctx context.Context, repoKey, name string) (model.Package, error)
// List returns a repository's packages ordered by name.
List(ctx context.Context, repoKey string, p kernel.Page) ([]model.Package, string, error)
// SearchNpm returns, ordered by name, an npm search's candidates (npm_search.go).
SearchNpm(ctx context.Context, q NpmSearch, p kernel.Page) ([]SearchCandidate, string, error)
// SearchNuGet returns, ordered by name, a NuGet search's candidates (nuget_search.go).
SearchNuGet(
ctx context.Context,
q NuGetSearch,
p kernel.Page,
) ([]SearchCandidate, string, error)
// Delete removes the package with its versions and file links.
Delete(ctx context.Context, id int64) error
// PutVersion creates or replaces version (v.PackageID, v.Version), then
// recomputes OrderKey for every version of the package with the
// package type's comparator (model.ComparatorFor), and returns v as
// stored.
PutVersion(ctx context.Context, v model.PackageVersion) (model.PackageVersion, error)
// Version returns one version of a package.
Version(ctx context.Context, packageID int64, version string) (model.PackageVersion, error)
// Versions returns a package's versions ordered by OrderKey, then
// version string.
Versions(ctx context.Context, packageID int64) ([]model.PackageVersion, error)
// DeleteVersion removes a version and its file links and recomputes the
// order keys of the rest.
DeleteVersion(ctx context.Context, id int64) error
// LinkFile records that an item belongs to a version; linking twice is
// not an error. kernel.ErrNotFound when the version or the item is missing.
LinkFile(ctx context.Context, f model.VersionFile) error
// Files returns the item IDs of a version, ordered.
Files(ctx context.Context, versionID int64) ([]int64, error)
// VersionOf returns the version an item belongs to, the one with the
// lowest ID when several link it.
VersionOf(ctx context.Context, itemID int64) (model.PackageVersion, error)
// RecordVersionDownload sets the version's LastDownloaded.
RecordVersionDownload(ctx context.Context, versionID int64, at time.Time) error
PackageVersionNames
PackagePages
}
PackageStore persists the package index of decision 0018.
type PackageVersionNames ¶
type PackageVersionNames interface {
// VersionNames returns the version strings of a package in the order
// Versions returns its versions: OrderKey, then version string. A
// package with no versions, or none at all, has none.
VersionNames(ctx context.Context, packageID int64) ([]string, error)
// CountVersions returns how many versions a package has.
CountVersions(ctx context.Context, packageID int64) (int, error)
// VersionNamesAt returns the version strings at offset of limit in
// the order VersionNames returns them, or in the reverse order when
// newestFirst is set.
VersionNamesAt(
ctx context.Context,
packageID int64,
newestFirst bool,
offset, limit int,
) ([]string, error)
}
PackageVersionNames reads a package's version strings without their records. Puppet's, Ansible's and Chef's lists page newest first, the order the package index holds for them (model.CompareForge and model.CompareGalaxy): a caller who may read every version is counted and paged here (CountVersions, VersionNamesAt), and one whose permissions name paths has each name checked by the handler, which reads the records of its page alone (#1404, #1426).
type ReleaseName ¶
ReleaseName is a version ReleasesAt or RangeVersionsAt lists: its package's ID and name, and the version string, whose record PackageStore.Version reads.
type RemoteCacheStore ¶
type RemoteCacheStore interface {
Source(ctx context.Context, repoKey string) (model.SourceIdentity, error)
Begin(ctx context.Context, key model.RemoteCacheKey) (model.RemoteCacheToken, error)
Read(ctx context.Context, key model.RemoteCacheKey) (model.RemoteCacheEntry, error)
// List includes raw metadata, negatives and tombstones, ordered by opaque
// key.
List(
ctx context.Context,
repoKey, prefix string,
p kernel.Page,
) ([]model.RemoteCacheEntry, string, error)
// Exact lists only this canonical path, never its descendants.
Exact(
ctx context.Context,
repoKey, path string,
p kernel.Page,
) ([]model.RemoteCacheEntry, string, error)
Check(ctx context.Context, token model.RemoteCacheToken) error
// Put replaces state after checking the token, advances Revision, and owns
// the raw metadata blob reference when ItemID is zero. Item-backed entries
// do not add another reference. Empty entries are durable path tombstones.
Put(
ctx context.Context,
token model.RemoteCacheToken,
entry model.RemoteCacheEntry,
) (model.RemoteCacheEntry, error)
Negative(ctx context.Context, token model.RemoteCacheToken, until time.Time) error
Revalidate(ctx context.Context, token model.RemoteCacheToken, at time.Time) error
Touch(ctx context.Context, token model.RemoteCacheToken, at time.Time) error
// Evict clears exactly this representation and advances its epoch. It
// releases raw references; callers remove item-backed content separately.
Evict(ctx context.Context, token model.RemoteCacheToken) error
// Invalidate fences every matching path, including empty in-flight entries.
// MetadataOnly expires metadata and clears negatives, preserving binaries.
// Otherwise entries become tombstones and release raw metadata references.
Invalidate(ctx context.Context, repoKey, prefix string, metadataOnly bool) (int64, error)
State(ctx context.Context, repoKey string) (model.RemoteSourceState, error)
PutState(ctx context.Context, repoKey string, state model.RemoteSourceState) error
}
RemoteCacheStore persists raw upstream representations and their CAS fences. All writes join Store.Tx. Begin precedes network I/O; Check/Put run in the publication transaction. kernel.ErrConflict means the caller must start a new read.
type ReplicaIndex ¶
type ReplicaIndex interface {
// Put creates or replaces the record (r.SHA256, r.Member);
// kernel.ErrInvalid without both.
Put(ctx context.Context, r mirror.BlobReplica) error
// Get returns one record.
Get(ctx context.Context, sha256, member string) (mirror.BlobReplica, error)
// ForBlob returns a blob's records ordered by member.
ForBlob(ctx context.Context, sha256 string) ([]mirror.BlobReplica, error)
// List returns matching records oldest update first, by (Updated, SHA256,
// Member), which is the order the repair worker drains them in.
List(
ctx context.Context,
f mirror.ReplicaFilter,
p kernel.Page,
) ([]mirror.BlobReplica, string, error)
// Delete removes one record.
Delete(ctx context.Context, sha256, member string) error
// DeleteBlob removes every record of a blob and returns how many.
DeleteBlob(ctx context.Context, sha256 string) (int64, error)
// Counts returns the number and size of records per member and state,
// ordered by (member, state).
Counts(ctx context.Context) ([]mirror.ReplicaCount, error)
// UnderReplicated counts the blobs with fewer than redundancy present
// records. A blob with a deleting record is being deleted and is not
// counted; neither is a blob with no records at all, which the repair
// worker's backfill brings into the index.
UnderReplicated(ctx context.Context, redundancy int) (int64, error)
// SoleCopies counts, per member, the blobs whose only present record is
// on that member. Blobs being deleted are left out, as UnderReplicated
// leaves them out. A member holding sole copies cannot be removed from
// a mirror without losing them: repair never reads from a member that
// is no longer configured.
SoleCopies(ctx context.Context) (map[string]int64, error)
}
ReplicaIndex records which mirror members hold which blobs (decision 0028): the blob_replicas table, and cold_blob_replicas for the archive tier.
type RepoFilter ¶
type RepoFilter struct {
Class repo.Class
PackageType repo.PackageType
ProjectKey string
}
RepoFilter narrows repository listings; empty fields match everything.
type RepoListing ¶
type RepoListing struct {
Class repo.Class
ProjectKey string
// PackageTypes, when not nil, lists only repositories of one of them.
PackageTypes []repo.PackageType
Visible []RepoSet
// Limit caps the window, and 0 lists every matching repository. Offset
// skips that many matching repositories before a capped window; it
// needs a Limit, as Get Repositories' offset does.
Offset, Limit int
// After, when set, starts the list after the repository of that key:
// the keyset continuation of a caller that walks the whole list a
// window at a time (#1409). A repository created or removed during the
// walk shifts no later window, as an Offset would.
After string
// Count asks for Total, the number of matching repositories on every
// page together.
Count bool
}
RepoListing asks RepoStore.Page for a window of the repository list ordered by key. Visible narrows it to the repositories every one of its sets holds, which is how a caller's visibility reaches the query; no set lists every repository.
type RepoPage ¶
type RepoPage struct {
Repos []RepoSummary
More bool
Total int
}
RepoPage is one window of a RepoListing: its repositories, whether more match after them, and the total when the listing asked for a count.
type RepoSet ¶
RepoSet is a set of repositories: every one, or those of the listed classes together with those of the listed keys. The zero RepoSet holds none.
type RepoStore ¶
type RepoStore interface {
// Create stores c; kernel.ErrConflict when the key exists.
Create(ctx context.Context, c repo.Config) error
// Get returns the configuration, including passwords and sensitive headers.
Get(ctx context.Context, key string) (repo.Config, error)
// Update replaces the stored configuration; kernel.ErrNotFound when absent.
Update(ctx context.Context, c repo.Config) error
// Delete removes the configuration only. Content is removed through
// ItemStore.Delete and the package index through PackageStore.
Delete(ctx context.Context, key string) error
// List returns every matching repository ordered by key. Artifactory
// lists repositories unpaged, so this does too.
List(ctx context.Context, f RepoFilter) ([]repo.Config, error)
// Page returns one window of the repositories l matches, ordered by key:
// the filters, the visibility, OFFSET and LIMIT apply in the store, which
// reads one repository past the window to tell whether more follow, and
// counts the matches only when l asks. It reads no secret.
Page(ctx context.Context, l RepoListing) (RepoPage, error)
// Including returns the keys of the virtual repositories that list key
// as a member, ordered.
Including(ctx context.Context, key string) ([]string, error)
// UsingKeypair returns the keys of repositories whose primary or
// secondary key pair is name, ordered.
UsingKeypair(ctx context.Context, name string) ([]string, error)
}
RepoStore persists repository configurations. Remote passwords and sensitive HTTP header values are sealed outside their documents; the virtual member list and the key pair references are mirrored into tables so Including and UsingKeypair are indexed lookups.
type RepoSummary ¶
type RepoSummary struct {
Key string
Class repo.Class
PackageType repo.PackageType
Description string
URL string
}
RepoSummary is the part of a repository's configuration a list shows. A remote's entry shows its upstream URL and, when it shares its configuration, where to read it (7.161.26's RepositoriesResource.addRemoteRepoDetails), so URL and Shared are set for a remote repository only.
func SummaryOf ¶
func SummaryOf(c repo.Config) RepoSummary
SummaryOf is the RepoSummary of the repository c.
type RepoUsage ¶
RepoUsage is one repository's (or one remote cache's) content totals for the storage summary.
type SearchCandidate ¶
type SearchCandidate struct {
Package model.Package
Versions []model.PackageVersion
}
SearchCandidate is a package a text search may list (SearchNpm and SearchNuGet), with every one of its versions, ordered as PackageStore.Versions orders them.
func CandidatesAt ¶
func CandidatesAt( ctx context.Context, s PackagePages, r PackageRange, offset, limit int, ) ([]SearchCandidate, int, error)
CandidatesAt returns the packages of r at offset of limit (PackagePages.PackagesAt), each with its versions (Candidates), and how many packages the page held, which is fewer than limit only past the range's end.
type Store ¶
type Store interface {
tx.Runner
Repos() RepoStore
RemoteCache() RemoteCacheStore
Items() ItemStore
Blobs() BlobIndex
Replicas() ReplicaIndex
Trash() TrashStore
Packages() PackageStore
GitLFSLocks() GitLFSLockStore
BowerRegistrations() BowerRegistrationStore
UploadDigests() UploadDigestStore
Builds() BuildStore
ArchivedItems() ArchivedItemStore
ColdBlobs() BlobIndex
ColdReplicas() ReplicaIndex
}
Store is every store the artifacts module owns. All of them take part in the caller's unit of work (tx.Runner); ColdBlobs and ColdReplicas index the cold tier with the same code as the hot ones.
type TrashStore ¶
type TrashStore interface {
// Add stores e and returns it with its assigned ID.
Add(ctx context.Context, e model.TrashEntry) (model.TrashEntry, error)
// Get returns the entry with id.
Get(ctx context.Context, id int64) (model.TrashEntry, error)
// Find returns the entries for an original repository and full path,
// newest first (entries without a deletion time last). A path that does
// not split into parent and name matches nothing.
Find(ctx context.Context, repoKey, fullPath string) ([]model.TrashEntry, error)
// List returns entries from repoKey ("" for every repository) whose
// original full path is prefix or below it ("" for all), ordered by
// (repository, path, name, ID).
List(
ctx context.Context,
repoKey, prefix string,
p kernel.Page,
) ([]model.TrashEntry, string, error)
// BelowByPath lists the entries below dir in the trash can's tree:
// every entry for "", else those whose TrashPath starts with dir and a
// slash. They are ordered by TrashPath byte by byte, then by ID, the
// order the storage API's views of the trash can list its tree in, so
// those views read it a page at a time (#1409).
BelowByPath(
ctx context.Context,
dir string,
p kernel.Page,
) ([]model.TrashEntry, string, error)
// Delete removes an entry.
Delete(ctx context.Context, id int64) error
// Expired returns entries deleted before t, oldest first, at most limit
// (kernel.DefaultLimit when zero).
Expired(ctx context.Context, before time.Time, limit int) ([]model.TrashEntry, error)
}
TrashStore persists the trash can.
type UploadDigestStore ¶
type UploadDigestStore interface {
// Put records d's SHA-1 and MD5 under d.SHA256; kernel.ErrInvalid when
// any of the three is empty. The SHA-256 names the content, so a
// second Put of the same content keeps the first row.
Put(ctx context.Context, d blob.Digests) error
// Get returns the SHA-256, SHA-1 and MD5 recorded for sha256;
// kernel.ErrNotFound when none is.
Get(ctx context.Context, sha256 string) (blob.Digests, error)
}
UploadDigestStore keeps the SHA-1 and MD5 an upload computed, by the content's SHA-256, for a protocol whose item is stored by a later request: a Hugging Face LFS object, uploaded before the commit that names its path. Every blob store answers Stat with the size and SHA-256 alone, so without it the commit would store the item without the two checksums 7.x keeps for every file (#1581).
type VersionTally ¶
type VersionTally struct {
// Packages is how many packages it counted, at most its limit.
Packages int
// Versions is how many versions they hold, and MostVersions the most
// one of them holds.
Versions, MostVersions int
}
VersionTally is what TallyVersions counts.