Documentation
¶
Overview ¶
Package format is the contract between the item service and the package formats (decision 0032): the hooks every format implements, the optional interfaces a format adds for what it needs, the environment they run in, and the RejectionError a format refuses a request with. The item service calls the hooks on every write, whichever API carried it, so a format's package index (decision 0018) and derived items stay consistent with the item tree, which remains the source of truth.
Each ecosystem has a subpackage named after it (repo-layout.md), and internal/format/formats picks one for a package type. A format package never imports internal/server, so formats speak to clients only through RejectionError.
Index ¶
- Constants
- func UniqueSnapshots(c repo.Config) int
- type AcceptedError
- type Admitter
- type Annotation
- type AnnotationAdmitter
- type Annotator
- type Blobs
- type Class
- type Classifier
- type Derived
- type Download
- type Env
- type FolderAdmitter
- type Handler
- type Inspector
- type Layouts
- type Op
- type PathReindexer
- type Reindexer
- type RejectionError
- type Resolver
- type SidecarKeeper
- type SidecarOwner
- type TransferSourceGuard
- type WorkRef
- type WorkRequest
- type Worker
- type Write
- type WriteGuard
Constants ¶
const ( // KindReindex rebuilds a repository's index, keyed by the repository's // key: requests made before a run begins coalesce into it. KindReindex = "reindex" // KindReindexNoProps keeps Opkg's writeProps=0 request distinct from the // normal reindex queue item, so coalescing cannot change its semantics. KindReindexNoProps = "reindex.noprops" // KindReindexPath rebuilds the part of a repository's index that the // files under a path give, keyed by "<repository key>/<path>", since // repository keys hold no slash. A key of its own per path keeps one // path's request from taking the place of another's, as the payload of // a coalesced request would. KindReindexPath = "reindex.path" )
The kinds of work the persistent work queue runs for the JFrog reindex operations of every format (decision 0033), which 7.x schedules rather than runs before it answers. The item service runs them through the format of the repository's package type, so a Reindexer needs no kind of its own, and a repository that is gone, or whose format keeps no index, owes nothing.
const MinUniqueSnapshots = 2
MinUniqueSnapshots is the fewest unique builds a maxUniqueSnapshots cleanup keeps, whatever the limit: "Artifactory requires that you store a minimum of 2 unique snapshots" (JFrog KB, "How does the max unique snapshots parameter work", 2025-05-15). So a limit of 1 keeps two; whether 7.x refuses a limit of 1 instead is on #216.
Variables ¶
This section is empty.
Functions ¶
func UniqueSnapshots ¶
UniqueSnapshots is how many unique builds of a snapshot c's cleanup keeps: 0 when c sets no maxUniqueSnapshots, which keeps every build, and otherwise never fewer than MinUniqueSnapshots. Maven's cleanup reads it when it runs, so a limit set back to 0 since the deploy that marked a package deletes nothing (RTDEV-93991, SaaS 7.164.0). npm ignores the limit, as JFrog intends (RTFACT-27078, decision 0034).
Types ¶
type AcceptedError ¶
type AcceptedError struct {
Status int
}
AcceptedError is a format's answer that a write succeeds without being made. Artifactory takes some uploads of what it computes itself, such as Maven's snapshot metadata and the checksums of any metadata, with a success status and stores nothing. Admit returns it, as an error, only for an OpDeploy or an OpChecksum; the HTTP layer answers Status with an empty body, and an exploded archive skips the entry.
func (*AcceptedError) Error ¶
func (a *AcceptedError) Error() string
type Admitter ¶
type Admitter interface {
Admit(ctx context.Context, env Env, c repo.Config, w Write) (Write, error)
}
Admitter is a format that checks a file write before it is made: a deploy or a checksum upload inside the write's transaction, and the target of a copy or move while it is planned. It returns the write as it should happen, with the path rewritten or properties added, or refuses it with a *RejectionError. A refused copy or move target is reported and skipped, as other per-item failures are. The generic format, which every format embeds, checks blackedOut, includesPattern and excludesPattern here; a format that overrides Admit calls those checks itself.
type Annotation ¶
type Annotation struct {
// Set holds the keys set or replaced, with their new values.
Set types.Properties
// Removed lists the keys removed.
Removed []string
// At is when the change was made. A hook that writes properties in
// turn writes them at At, so they read as part of the same change
// (types.Item.PropertiesModified) rather than a later one.
At time.Time
}
Annotation is a change to an item's properties.
type AnnotationAdmitter ¶
type AnnotationAdmitter interface {
AdmitAnnotation(ctx context.Context, env Env, c repo.Config, it types.Item, a Annotation) error
}
AnnotationAdmitter is a format that checks a change to an item's properties before it is made, such as the Terraform backend's, whose lock properties only its own API changes (decision 0041). The item service asks it of every change Service.Annotate makes: the properties API, AQL properties.update, a folder create's matrix parameters and a promotion's. A deploy's properties reach Admit with the write, and a restore brings back, or a copy or move carries, properties that were set already, so none of those asks.
type Annotator ¶
type Annotator interface {
Annotated(ctx context.Context, env Env, c repo.Config, it types.Item, a Annotation) error
}
Annotator is a format whose index follows item properties, as npm's dist-tags do. The item service calls Annotated inside the transaction of every property write: the properties API, matrix parameters on a deploy or a folder, AQL properties.update, a copy or move carrying properties over, a restore, and a promotion tagging what it promoted.
type Blobs ¶
type Blobs interface {
// Open returns the content stored under a SHA-256 for random access;
// the caller closes it.
Open(ctx context.Context, sha256 string) (io.ReadSeekCloser, blob.Info, error)
// Stat returns a blob's Info without opening it.
Stat(ctx context.Context, sha256 string) (blob.Info, error)
}
Blobs reads stored content: the read half of blob.Store.
type Class ¶
type Class int
Class says what kind of content an item is, for cache expiry (P9), replication (P11) and federation (P13).
const ( // ClassUnique is content only its deployer can supply again, such as a // jar or an image layer. ClassUnique Class = iota + 1 // ClassMetadata is deployed content that describes others and may // change under the same path, such as a Docker tag's manifest. ClassMetadata // ClassDerived is written by the format itself (Env.Derive), so // replication and federation skip it and each side recomputes it. ClassDerived )
Classes of item.
type Classifier ¶
Classifier is a format that tells its classes of item apart.
type Derived ¶
type Derived struct {
Repo repo.Config
Cached bool
// Path is repository-relative, without a leading slash.
Path string
Body io.Reader
Properties types.Properties
// By is recorded as the item's creator and modifier.
By string
}
Derived is an item a format writes itself. Its content goes into the blob store and the item into the tree, replacing a file at Path; a folder in the way is an error.
type Download ¶
type Download struct {
// Path is the requested repository-relative path.
Path string
Cached bool
// Matrix holds the request's matrix parameters, which the file served
// must match.
Matrix types.Matrix
// Readable reports whether the caller may read a file of the
// repository; nil reads every file.
Readable func(fullPath string) bool
}
Download is a file a client asks for.
type Env ¶
type Env struct {
// Store is the metadata store.
Store store.Store
// Blobs reads stored content, such as the file a hook indexes. Formats
// write content only through Derive and remove it only through
// Underive.
Blobs Blobs
// Now is the clock.
Now func() time.Time
// Layouts resolves repository layouts by name, compiling each at most
// once per operation.
Layouts Layouts
// Derive writes a derived item, such as maven-metadata.xml, inside the
// current transaction without calling any hook, so a format's own
// output never re-enters it. A format must not derive an item another
// format would need to index.
Derive func(ctx context.Context, d Derived) (types.Item, error)
// Underive removes the file at path, which the format derived, without
// any hook and past the trash can, releasing its content; nothing at
// path is no error. A restore would bring back data the format
// recomputes anyway.
Underive func(ctx context.Context, c repo.Config, cached bool, path string) error
// Remove deletes the files at paths, of c's own content, as a client's
// delete does: through every hook, the format's own included, and into
// the trash can when it is on, recorded as deleted by by. It then
// prunes the folders those deletes left empty, up to the repository
// root. A path with nothing at it is skipped. It is one transaction, so
// a failure removes none. Derived work removes deployed files with it,
// such as Maven's maxUniqueSnapshots cleanup.
Remove func(ctx context.Context, c repo.Config, paths []string, by string) error
// Enqueue asks the persistent work queue for kind's work on key
// (decision 0033). Called with a hook's ctx, the work is asked for
// exactly when the write commits, and not at all after a rollback.
Enqueue func(ctx context.Context, kind, key string, payload []byte) error
// Move moves the file at from to to, both in c, as a move by the REST
// API makes it, with every hook, by as its mover, and never over an
// item at to. It returns why the file did not move, or "" once it has.
// It is for a format's Work, such as npm's strict-layout conversion,
// which moves files a client stored where the format cannot index them.
Move func(ctx context.Context, c repo.Config, from, to, by string) (string, error)
// Inspection is what the format's Inspect returned for the file being
// written. It is nil when the format inspects nothing, and on a
// restore, which runs inside its caller's transaction: a hook that needs
// one then inspects the content itself.
Inspection any
// ReindexSource binds a remote rebuild to the source accepted when queued.
// The format must recheck it in its publication transaction.
ReindexSource *types.SourceIdentity
// CheckReindex revalidates the original caller before publication of queued
// remote maintenance. Trusted direct maintenance leaves it nil.
CheckReindex func(context.Context) error
// SkipProperties is set only by an explicit reindex operation that asks
// the format to rebuild metadata without rewriting item properties.
SkipProperties bool
}
Env is what a hook runs with. The item service builds one per operation; inside a hook, ctx carries the operation's transaction, which Store, Derive and Enqueue join.
type FolderAdmitter ¶
type FolderAdmitter interface {
AdmitFolder(ctx context.Context, env Env, c repo.Config, path string) error
}
FolderAdmitter is a format that checks a folder create before it is made, as Admitter checks a file write: every folder the item service's MakeFolder makes, which is a client's folder create and the folder entries of an archive exploded without atomicity. The folders a file write creates above its file are not asked, since Admit was asked about the file.
type Handler ¶
type Handler interface {
// Deployed runs after a file was stored at it (new or overwritten), by a
// deploy, a copy, a move or a restore, once its properties are set.
Deployed(ctx context.Context, env Env, c repo.Config, it types.Item) error
// Deleting runs for each file before it is removed from the tree.
Deleting(ctx context.Context, env Env, c repo.Config, it types.Item) error
// Deleted runs once after a delete or a move removed items from the tree
// and the item service pruned the versions left without files. A format
// whose versions or packages depend on more than their own files (a
// Docker tag exists while its folder holds a manifest) corrects the
// index here.
Deleted(ctx context.Context, env Env, c repo.Config, removed []types.Item) error
}
Handler is one package type's required hooks. All run inside the transaction that changes the item, so an error rolls the change back.
type Inspector ¶
type Inspector interface {
Inspect(ctx context.Context, env Env, c repo.Config, w Write) (any, error)
}
Inspector is a format that reads deployed content before the write's transaction, so no decompression or parsing holds the database's write lock. The item service calls Inspect once the content is in the blob store and hands the result to Admit and Deployed as Env.Inspection. A write the transaction then refuses leaves the content for garbage collection.
type Layouts ¶
Layouts resolves a repository layout by name: one the descriptor stored, else a bundled one.
type Op ¶
type Op int
Op is the kind of write Admit is asked about.
const ( // OpDeploy stores content at a path: by upload, by checksum, or as an // entry of an exploded archive. OpDeploy Op = iota + 1 // OpChecksum records a client checksum for the file at the path, from a // sidecar upload ("a/b.jar.sha1" names the file "a/b.jar"). OpChecksum // OpCopy and OpMove land an existing file at the path. OpCopy OpMove )
Writes a format admits.
type PathReindexer ¶
type PathReindexer interface {
Reindexer
ReindexPath(ctx context.Context, env Env, c repo.Config, path string) error
}
PathReindexer is a Reindexer that can rebuild the part of its index that the files under one path give, for Helm's partial reindex. The item service rebuilds the whole repository for a Reindexer that is not one, which leaves the same index at a greater cost.
type Reindexer ¶
Reindexer is a format that can rebuild its index of a repository from the item tree, for a JFrog reindex operation and for maintenance. It manages its own transactions, so a large repository need not be rebuilt in one.
type RejectionError ¶
RejectionError is a format's refusal of a request. The HTTP layer answers it with Status and Message in the envelope of the surface the request arrived on.
func Rejectf ¶
func Rejectf(status int, format string, args ...any) *RejectionError
Rejectf returns a RejectionError with a formatted message.
func (*RejectionError) Error ¶
func (r *RejectionError) Error() string
type Resolver ¶
type Resolver interface {
Resolve(ctx context.Context, env Env, c repo.Config, d Download) (string, error)
}
Resolver is a format whose downloads may name a file other than the one requested, such as a Maven version token. Resolve runs before a GET or HEAD looks the path up and returns the path to look up instead.
type SidecarKeeper ¶
type SidecarKeeper interface {
// Sidecars returns the paths in c of the sidecars the file at path
// owns, whether or not any exists, and none for a file that owns none.
// The item service asks it of owners only, never of a sidecar it
// found, so a sidecar of a sidecar is not followed.
Sidecars(c repo.Config, path string) []string
}
SidecarKeeper is a format some of whose files own sidecars: files at paths named after theirs that are of use only beside them, such as a Helm chart's provenance file, which helm fetches at the chart's URL plus ".prov" (decision 0039). The item service keeps a sidecar with its owner:
- a delete of the owner deletes it in the same operation, into the trash can when that is on;
- a copy or move of the owner takes it to the sidecar's path beside the owner's target, under the same rules as the owner, and the owner does not go without it;
- a trash restore of the owner restores it when the same delete removed it.
On its own a sidecar is an ordinary file: deleting, copying or moving it touches nothing else, and a deploy over its owner leaves it as it is. It is never a version file, so the format's index links no sidecar, and it is no checksum file either: that is SidecarOwner.
type SidecarOwner ¶
type SidecarOwner interface {
OwnsSidecars()
}
SidecarOwner is a format whose repositories take every upload named as a checksum sidecar ("a/b.jar.sha1") as a checksum of its file, as Artifactory does: Admit sees each as an OpChecksum, whether or not the file exists, and one whose file is missing is refused. In the other formats such an upload without its file is stored as a file of its own.
type TransferSourceGuard ¶
type TransferSourceGuard interface {
GuardTransferSource(ctx context.Context, env Env, c repo.Config, it types.Item) error
}
TransferSourceGuard checks whether a stored file may leave its source format through a copy or move. It runs for each file, including folder descendants, before destination inspection. RejectionError reports and skips that file; other errors abort planning before any items change. Destination admission remains the target format's responsibility.
type WorkRef ¶
type WorkRef struct {
Kind, Key string
}
WorkRef names one item of the persistent work queue: a kind and a key.
type WorkRequest ¶
type WorkRequest struct {
// By is recorded as the mover of what npm's strict-layout conversion
// moves.
By string `json:"by,omitempty"`
SkipProperties bool `json:"-"`
// Source fences a queued remote reindex across edits and delete/recreate.
Source *types.SourceIdentity `json:"source,omitempty"`
// Credential is an internal reference to the original authenticated caller.
// It contains no password, bearer token or cached permissions.
Credential json.RawMessage `json:"credential,omitempty"`
}
WorkRequest is the payload of the work a JFrog operation queues: who asked for it.
type Worker ¶
type Worker interface {
// WorkKinds are the kinds the format enqueues: code constants, unique
// across formats.
WorkKinds() []string
// Work runs one item of one of the format's kinds, outside any
// transaction. It must be idempotent and read the state it derives from
// afresh, since an item can run again and coalesces every request made
// before the run began.
Work(ctx context.Context, env Env, item types.WorkItem) error
// Owed names the work a download of path from c must see done before
// it is read, so a client never reads derived data that lags a
// completed write.
Owed(c repo.Config, cached bool, path string) []WorkRef
}
Worker is a format that queues derived work with Env.Enqueue and runs it from the persistent work queue (decision 0033), such as Maven's metadata.
type Write ¶
type Write struct {
// By is the actor recorded for a deploy, empty for other write kinds.
// It binds staged publication to its creator without HTTP dependencies.
By string
Op Op
// Path is the repository-relative target. Admit may change it, and the
// write then lands there.
Path string
Cached bool
// Properties are set on the item with the write: a deploy's matrix
// parameters, or the properties a copy or move carries over. Admit may
// add or change them.
Properties types.Properties
// Size and Checksums describe the content. For OpChecksum, Checksums is
// empty and Size is the length of the sidecar's body as the client
// declared it, or -1.
Size int64
Checksums types.Checksums
// From is the source of a copy or move.
From types.Item
}
Write is a file write as a format sees it before it happens.
type WriteGuard ¶
type WriteGuard interface {
GuardWrite(ctx context.Context, env Env, c repo.Config, w Write) error
}
WriteGuard rechecks invariants that depend on concurrent writes inside the transaction, before a deploy, copy or move lands. Unlike Admit, which also plans transfers outside a transaction, this hook may acquire database locks that must survive until commit. A format RejectionError skips a transfer item, as planning refusals do; other errors roll back the operation. Restores bypass admission and this guard, preserving their existing semantics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentpackages validates and indexes APM Agent Packages ZIP archives.
|
Package agentpackages validates and indexes APM Agent Packages ZIP archives. |
|
Package agentplugins validates and indexes local Agent Plugin ZIP bundles.
|
Package agentplugins validates and indexes local Agent Plugin ZIP bundles. |
|
Package aieditorextensions owns VS Code gallery identities and cache paths.
|
Package aieditorextensions owns VS Code gallery identities and cache paths. |
|
Package alpine implements Alpine APK v2 package and index metadata.
|
Package alpine implements Alpine APK v2 package and index metadata. |
|
Package bazelmodules validates Bazel module registry uploads.
|
Package bazelmodules validates Bazel module registry uploads. |
|
Package bower validates Bower package trees and indexes versions from their bower.json manifest.
|
Package bower validates Bower package trees and indexes versions from their bower.json manifest. |
|
Package cargo validates crates and supplies Cargo sparse-index records.
|
Package cargo validates crates and supplies Cargo sparse-index records. |
|
Package chef validates Chef cookbook archives and maintains their native index.
|
Package chef validates Chef cookbook archives and maintains their native index. |
|
Package composer validates hosted Composer archives and their package identity.
|
Package composer validates hosted Composer archives and their package identity. |
|
Package conan owns Conan's on-disk revision layout and write policy.
|
Package conan owns Conan's on-disk revision layout and write policy. |
|
Package debian implements Debian package and repository metadata.
|
Package debian implements Debian package and repository metadata. |
|
Package docker is the storage layout of Docker and OCI images in a repository's item tree (decision 0031), which the JFrog CLI reads with AQL and the storage API: an image is a folder, each tag a folder of its own below it and each manifest pushed by digest a folder named sha256:<hex>, and every blob a file named sha256__<hex> in the folders of the images that use it.
|
Package docker is the storage layout of Docker and OCI images in a repository's item tree (decision 0031), which the JFrog CLI reads with AQL and the storage API: an image is a folder, each tag a folder of its own below it and each manifest pushed by digest a folder named sha256:<hex>, and every blob a file named sha256__<hex> in the folders of the images that use it. |
|
Package formats picks the format of a package type.
|
Package formats picks the format of a package type. |
|
Package formattest is the contract suite for package formats (decision 0032).
|
Package formattest is the contract suite for package formats (decision 0032). |
|
Package generic is the format of generic repositories: files without package metadata, so nothing is indexed.
|
Package generic is the format of generic repositories: files without package metadata, so nothing is indexed. |
|
Package gitlfs owns the content-addressed object layout of Git LFS repositories.
|
Package gitlfs owns the content-addressed object layout of Git LFS repositories. |
|
Package golang is the format of Go module repositories (decision 0035).
|
Package golang is the format of Go module repositories (decision 0035). |
|
Package helm is the format of classic Helm chart repositories (decision 0039); Helm OCI repositories are the Docker format's.
|
Package helm is the format of classic Helm chart repositories (decision 0039); Helm OCI repositories are the Docker format's. |
|
Package hex validates Hex tarballs and extracts metadata needed by the signed registry v2 protocol.
|
Package hex validates Hex tarballs and extracts metadata needed by the signed registry v2 protocol. |
|
Package huggingface owns the current Machine Learning layout used by Hugging Face model and dataset repositories.
|
Package huggingface owns the current Machine Learning layout used by Hugging Face model and dataset repositories. |
|
xet
Package xet validates the public Hugging Face Xet chunk and shard wire formats.
|
Package xet validates the public Hugging Face Xet chunk and shard wire formats. |
|
Package luarocks indexes root-level rockspecs and rocks and derives the LuaRocks manifest consumed by the native client.
|
Package luarocks indexes root-level rockspecs and rocks and derives the LuaRocks manifest consumed by the native client. |
|
Package machinelearning owns FrogML's versioned model layout and publication invariants.
|
Package machinelearning owns FrogML's versioned model layout and publication invariants. |
|
Package maven is the format of maven, gradle, ivy and sbt repositories (decision 0036): Maven's naming predicates, the coordinates a repository's layout reads from a path, and the package index of decision 0018, kept by the hooks on every write path and rebuilt by Reindex.
|
Package maven is the format of maven, gradle, ivy and sbt repositories (decision 0036): Maven's naming predicates, the coordinates a repository's layout reads from a path, and the package index of decision 0018, kept by the hooks on every write path and rebuilt by Reindex. |
|
Package nix validates Nix binary-cache metadata and archive integrity.
|
Package nix validates Nix binary-cache metadata and archive integrity. |
|
Package npm is the format of npm repositories (decision 0034).
|
Package npm is the format of npm repositories (decision 0034). |
|
Package nuget is the format of NuGet repositories (decision 0038).
|
Package nuget is the format of NuGet repositories (decision 0038). |
|
Package opkg reads bounded IPK archives and their control metadata.
|
Package opkg reads bounded IPK archives and their control metadata. |
|
Package p2 validates Eclipse p2 update-site paths and bounded metadata.
|
Package p2 validates Eclipse p2 update-site paths and bounded metadata. |
|
Package pub validates Dart pub archives and maintains their native index.
|
Package pub validates Dart pub archives and maintains their native index. |
|
Package puppet validates Puppet module archives and maintains their native index.
|
Package puppet validates Puppet module archives and maintains their native index. |
|
Package pypi is the format of PyPI repositories (decision 0037).
|
Package pypi is the format of PyPI repositories (decision 0037). |
|
Package rpm reads bounded RPM v4 headers for native repository metadata.
|
Package rpm reads bounded RPM v4 headers for native repository metadata. |
|
Package skills indexes the canonical ZIP bundles of local Skills repositories.
|
Package skills indexes the canonical ZIP bundles of local Skills repositories. |
|
Package swift implements the Swift package registry's stored archive format.
|
Package swift implements the Swift package registry's stored archive format. |
|
Package terraform is the format of Terraform registry repositories (decision 0040): the modules and Terraform provider packages that users store in terraform repositories, which the module registry, the provider registry and the network mirror serve.
|
Package terraform is the format of Terraform registry repositories (decision 0040): the modules and Terraform provider packages that users store in terraform repositories, which the module registry, the provider registry and the network mirror serve. |
|
terraformtest
Package terraformtest builds Terraform registry content for tests (role 2 of epic #526: Terraform modules and Terraform provider packages that artifactweave stores): GPG key pairs, the files of a Terraform provider package's release laid out and signed as HashiCorp publishes them, and module zips.
|
Package terraformtest builds Terraform registry content for tests (role 2 of epic #526: Terraform modules and Terraform provider packages that artifactweave stores): GPG key pairs, the files of a Terraform provider package's release laid out and signed as HashiCorp publishes them, and module zips. |
|
Package terraformbackend is the format of Terraform backend repositories (decision 0041): the workspaces and states of Terraform's remote backend, kept as items under workspaces/<ws>/ as 7.x keeps them.
|
Package terraformbackend is the format of Terraform backend repositories (decision 0041): the workspaces and states of Terraform's remote backend, kept as items under workspaces/<ws>/ as 7.x keeps them. |
|
Package vagrant validates Vagrant boxes and indexes their deployment properties.
|
Package vagrant validates Vagrant boxes and indexes their deployment properties. |