model

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package model holds the artifacts module's entity values: items with their properties, statistics and trash records, packages and their versions with the version comparators, builds, remote cache entries and source identities, Bower registrations, Git LFS locks, archived items, the trash can and folder download settings, and the key pair roles of repositories.

Role

artifacts module, core layer, entity values. The module's store ports (artifacts/core/port) take and return them, and the artifacts services build on them. PackageType and the version comparators stay out of the kernel, because ComparatorFor takes a repository package type, and a kernel that named one would import a module (decision 0044, "Persistence"). The package imports the standard library, artifacts/api/repo (the package types), the kernel (checksums and item paths) and platform/blob (the blob row a raw remote cache entry owns).

Inputs

  • Full item paths, repository keys as clients send them, property keys and values, version strings with their package type, and build names, numbers and project keys to encode.

Outputs

  • Items: Item, RootItem, ResolveRepoKey, CacheSuffix, ItemStats, TrashRecord and TrashEntry; Properties with Set, Add, Has, Keys, Equal and Clone; ValidatePropertyKey, CheckPropertyKeyLength, TruncatePropertyValue, PropertyKeyMax, PropertyValueMax and BuildPropertyValueMax, with the sentinels ErrInvalidPropertyKey and ErrPropertyKeyTooLong; and Matrix, a download's matrix parameters.
  • Packages: Package, PackageVersion and VersionFile; VersionComparator with StringComparator and CreatedOrder, ComparatorFor, SortVersions and AssignOrderKeys; and CompareSemver, CompareNuGet, ComparePEP440, CompareMaven, CompareMercury, CompareForge (Puppet and Chef) and CompareGalaxy (Ansible), the orders their lists answer in, reversed.
  • Builds: Build, BuildRun, BuildName, BuildModule, BuildFile, BuildFileRef, BuildPromotion and BuildRetention, with BuildInfoRepo and EncodeBuildInfoSegment.
  • Remote cache: RemoteKind and its four kinds, RemoteCacheKey, RemoteCacheToken, RemoteCacheEntry, RemoteSmartState, RemoteSourceState and RemoteSmartPeer; and the source identity: RepositoryIncarnation, SourceGeneration, SourceKind with ExternalHTTP and ProjectRepository, and SourceIdentity.
  • BowerRegistration, GitLFSLock and ArchivedItem.
  • TrashcanSettings, FolderDownloadSettings, and KeypairRole with KeypairPrimary and KeypairSecondary.

Invariants

  • Properties keep each key's values sorted and unique, so listings and comparisons are deterministic.
  • A property key is at most PropertyKeyMax characters and is refused past it; a value is cut, never refused, to PropertyValueMax UTF-16 code units, or BuildPropertyValueMax for build and module properties, as Artifactory cuts it on write.
  • EncodeBuildInfoSegment equals the JFrog CLI's encoding byte for byte, because the CLI finds a build's document item by that path.
  • ComparatorFor gives each package type its own order, so retention, tag limits and latest-version resolution never borrow another ecosystem's rules (decision 0018).
  • The JSON tags on the trash record and the remote cache values are the stored document format, and the string constants (remote kinds, source kinds, key pair roles) are stored, so neither ever changes.

References

  • Decision 0004: docs/research/decisions/0004-storage-sql-metadata-and-blobs.md (the item model).
  • Decision 0007: docs/research/decisions/0007-remote-repositories.md (cached items, the remote cache and source identities).
  • Decision 0014: docs/research/decisions/0014-build-info.md (builds).
  • Decision 0018: docs/research/decisions/0018-package-index.md (packages, versions and their comparators).
  • Decision 0020: docs/research/decisions/0020-domain-model.md (one internal value per entity).
  • Decision 0024: docs/research/decisions/0024-cold-storage-tier.md (archived items).
  • Decision 0036: docs/research/decisions/0036-maven.md (the Mercury order).
  • Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence").
  • Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 187 and 188 (the artifacts module's core/model) and line 1058 (the shared types split into each module's core/model).
  • 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

Status

Implemented P2: items, properties, trash records, packages and the version comparators, archived items, the trash can settings and the key pair roles among the shared domain types (pull request 3). Later phases added folder download settings (pull request 62), builds (pull request 193), the Mercury order (pull request 233), the property limits (pull request 348), download matrices (pull request 355), source identities and the remote cache (pull requests 644 and 646), Git LFS locks (pull request 849) and Bower registrations (pull request 912). Moved here in P9d.

Testing

  • model_test.go: item paths, repository key aliasing, properties and their limits, the trash record document and archived item expiry.
  • version_test.go: each comparator's order, ComparatorFor and sorting, and AssignOrderKeys.
  • list_order_test.go: CompareForge and CompareGalaxy against the handlers' x/mod/semver orders, including invalid versions and build metadata, and the order keys they assign (#1426).
  • build_test.go: the build-info segment encoding, BuildInfoRepo, a run's document item and its identity.
  • matrix_test.go: matrix parameters against a file's properties.

The metadata store's contract subtests store and read these values on its in-memory, SQLite and PostgreSQL stores.

Index

Constants

View Source
const (
	PropertyValueMax      = 2400
	BuildPropertyValueMax = 2048
)

PropertyValueMax and BuildPropertyValueMax are the longest property values the stores keep, in UTF-16 code units, as Artifactory's Java counts them. JFrog's 7.x documentation limits property values to 2400 characters ("JFrog Properties"); build and module properties keep 6.20's 2048 (BuildsDao and BuildModulesDao), which the documentation does not cover. Artifactory 6.20 cuts a longer value on write rather than refusing it (PropertiesDao), and so do the stores.

View Source
const CacheSuffix = "-cache"

CacheSuffix marks a remote repository's cache in item and AQL responses.

View Source
const PropertyKeyMax = 255

PropertyKeyMax is the longest property key, in characters: the limit JFrog's 7.x documentation gives ("JFrog Properties"), and the width of Artifactory's VARCHAR(255) key columns. Artifactory checks nothing before its database refuses a longer key (RTFACT-21394); artifactweave answers 400 (DV-059).

Variables

View Source
var ErrInvalidPropertyKey = errors.New("invalid property key")

ErrInvalidPropertyKey reports a property key that the matrix-parameter and properties-query syntaxes could not carry.

View Source
var ErrPropertyKeyTooLong = fmt.Errorf("%w: longer than %d characters",
	ErrInvalidPropertyKey, PropertyKeyMax)

ErrPropertyKeyTooLong reports a key longer than PropertyKeyMax. It wraps ErrInvalidPropertyKey.

Functions

func AssignOrderKeys

func AssignOrderKeys(c VersionComparator, versions []PackageVersion)

AssignOrderKeys sorts versions with c and sets OrderKey to each version's rank, starting at 1 for the oldest. Equivalent versions share a rank.

func BuildInfoRepo

func BuildInfoRepo(projectKey string) string

BuildInfoRepo returns the repository holding a project's build-info documents: artifactory-build-info for the default project ("" or "default") and <project>-build-info otherwise.

func CheckPropertyKeyLength

func CheckPropertyKeyLength(key string) error

CheckPropertyKeyLength returns ErrPropertyKeyTooLong for a key longer than PropertyKeyMax characters. The stores check it too: on PostgreSQL a key is indexed whole beside a value's prefix, and a much longer key would not fit a B-tree entry.

func CompareForge

func CompareForge(a, b string) int

CompareForge orders Puppet module and Chef cookbook versions as their lists order them newest first, reversed, so that a list reads the package's versions from its highest OrderKey down as one seek of the index (#1426). The lists compare golang.org/x/mod/semver's way, "v" prefixed, which sorts an invalid version below every valid one and ties invalid versions, and versions that differ only in build metadata; they then put the tied versions in byte order. Each tie is reversed here, so no two versions of a package share an OrderKey and the reversed order is the lists' own.

func CompareGalaxy

func CompareGalaxy(a, b string) int

CompareGalaxy orders Ansible collection versions as their version list orders them newest first, reversed (#1426). The list compares as CompareForge does, and left its ties, versions that differ only in build metadata, where an unstable sort left them: for twelve versions or fewer that was the order of its input, the index's earlier Maven order, then byte order, which this pins for every list. An invalid version, which no Ansible deploy admits, ties the others in byte order alone, as Maven's order is not consistent over such strings. Each tie is reversed here, as CompareForge reverses its own.

func CompareMaven

func CompareMaven(a, b string) int

CompareMaven orders Maven, Gradle, Ivy and SBT versions the way Maven's ComparableVersion does, so 1.0-SNAPSHOT < 1.0 < 1.0-sp1 and 1.10 > 1.9.

func CompareMercury

func CompareMercury(a, b string) int

CompareMercury orders versions the way Artifactory's versions and latest version searches do (Mercury's ComparableVersion): 1.0-SNAPSHOT < 1.0-alpha-1 < 1.0-rc1 < 1.0 < 1.0-sp1, and 1.10 > 1.9.

func CompareNuGet

func CompareNuGet(a, b string) int

CompareNuGet orders NuGet versions: up to four numeric components (NuGet keeps the legacy revision), then pre-release labels compared like semver but case-insensitively, which is how NuGet treats 1.0.0-Beta and 1.0.0-beta as one version.

func ComparePEP440

func ComparePEP440(a, b string) int

ComparePEP440 orders Python versions by epoch, release, pre-release, post-release, development release and local label with the sentinel rules of the packaging library: a final release sorts after its pre-releases and before its post-releases, and a version without a local label sorts before the same version with one.

func CompareSemver

func CompareSemver(a, b string) int

CompareSemver orders semantic versions: the numeric core first, then a release sorts after its pre-releases, and pre-release identifiers compare numerically when both are numeric, numeric before alphanumeric otherwise, with the longer list winning a shared prefix. Build metadata is ignored, as semver requires. A leading "v" is accepted because Go modules require it.

func EncodeBuildInfoSegment

func EncodeBuildInfoSegment(s string) string

EncodeBuildInfoSegment encodes a build name, number or project key as the CLI's encodeForBuildInfoRepository does: every whitespace rune becomes a space, the AQL-special characters are percent-encoded, and a space next to an encoded slash becomes %20.

func ResolveRepoKey

func ResolveRepoKey(key string) (stored string, cached bool)

ResolveRepoKey maps a key as a client sent it to the stored key and the cached flag: "maven-remote-cache" is the cache of "maven-remote". It is repo.ResolveKey, which access reads too, so the two cannot drift.

func SortVersions

func SortVersions(c VersionComparator, versions []PackageVersion)

SortVersions sorts versions oldest first in place.

func TruncatePropertyValue

func TruncatePropertyValue(v string, limit int) string

TruncatePropertyValue cuts v to at most limit UTF-16 code units. Java's substring, which Artifactory uses, can split a surrogate pair; here a character that would straddle the limit is dropped whole, so the result stays valid UTF-8.

func ValidatePropertyKey

func ValidatePropertyKey(key string) error

ValidatePropertyKey refuses keys that the ";key=value" matrix syntax and the "?properties=k=v|k2=v2" query syntax could not carry unambiguously, and keys CheckPropertyKeyLength refuses.

Types

type ArchivedItem

type ArchivedItem struct {
	ID             int64
	Namespace      string
	Item           Item
	Properties     Properties
	Stats          ItemStats
	PackageType    string
	PackageName    string
	PackageVersion string
	PolicyKey      string
	ExecutionID    int64
	ArchivedAt     time.Time
	ExpiresAt      time.Time
	ColdBlobSHA256 string
}

ArchivedItem is the record an archived item leaves behind: its full metadata, so a restore recreates it and AQL over archives can search it.

func (ArchivedItem) Expired

func (a ArchivedItem) Expired(now time.Time) bool

Expired reports whether the record is due for purging.

type BowerRegistration

type BowerRegistration struct {
	RepoKey string `json:"repoKey"` //nolint:tagliatelle // P9d renamed no JSON key (decision 0044)
	Name    string `json:"name"`
	URL     string `json:"url"`
}

BowerRegistration binds a registry name to a Git locator. It contains no credentials and belongs to one repository lifetime, independently of cache.

type Build

type Build struct {
	// ID is assigned by the store when the run is put.
	ID int64
	// ProjectKey is "" for the default project.
	ProjectKey string
	Name       string
	Number     string
	// Started is the document's start time, at millisecond precision in
	// the document; it stays fixed through promotion and replication.
	Started    time.Time
	URL        string
	Created    time.Time
	CreatedBy  string
	Modified   time.Time
	ModifiedBy string
	// Properties are the document's build-level properties, the AQL
	// build.property domain.
	Properties Properties
	Modules    []BuildModule
	// Document is the build-info JSON as published.
	Document []byte
}

Build is one run of a build (decision 0014). One name and number may be published several times, and each publish is a new run, so a run is identified by ProjectKey, Name, Number and Started together (research 22 §3.3). The document is kept as published, for the read API; the modules, properties and files are kept as rows, for the AQL build domains and the checksum searches.

func (Build) DocumentItem

func (b Build) DocumentItem() (repoKey, fullPath string)

DocumentItem returns where b's document is also stored as an item: the build-info repository and the full path within it. The CLI finds the item with AQL $match on these encoded segments, for LATEST and build-append (research 22 §3.3), so the encoding must equal the CLI's byte for byte.

func (Build) Run

func (b Build) Run() BuildRun

Run returns b's identity and timestamps, without its content.

type BuildFile

type BuildFile struct {
	// ID is a dependency's id; artifacts have none.
	ID   string
	Name string
	Type string
	Path string
	// Scopes are a dependency's scopes; artifacts have none.
	Scopes    []string
	Checksums kernel.Checksums
}

BuildFile is an artifact a module produced or a dependency it consumed. Its checksums link it to items, which is how the AQL build domains join (decision 0014). Build-info records sha1, sha256 and md5, so SHA512 is always empty here.

type BuildFileRef

type BuildFileRef struct {
	Run    BuildRun
	Module string
	File   BuildFile
}

BuildFileRef is a build file found by checksum, with the run and module it belongs to.

type BuildModule

type BuildModule struct {
	// ID is the module's id in the document. A module of type "build"
	// names another build as <name>/<number>.
	ID           string
	Type         string
	Properties   Properties
	Artifacts    []BuildFile
	Dependencies []BuildFile
}

BuildModule is one module of a run: what it produced and consumed.

type BuildName

type BuildName struct {
	ProjectKey  string
	Name        string
	LastStarted time.Time
}

BuildName is one build name with the start of its latest run, as GET /api/build lists them.

type BuildPromotion

type BuildPromotion struct {
	ID      int64
	BuildID int64
	Created time.Time
	// CreatedBy is the user who promoted.
	CreatedBy string
	Status    string
	Comment   string
	// CIUser is the CI user named in the promotion request.
	CIUser     string
	SourceRepo string
	// Repo is the target repository.
	Repo string
}

BuildPromotion records one promotion of a run (decision 0014).

type BuildReport

type BuildReport struct {
	// ID is assigned by the store; the replay's receipt names it.
	ID int64
	// Action is the build action that reported.
	Action     string
	ProjectKey string
	Name       string
	// BuildID is the run a promotion promoted, which its replay rechecks;
	// zero for a delete, whose runs are gone.
	BuildID int64
	// Report is the action's report as the build service encodes it.
	Report  []byte
	Created time.Time
	Expires time.Time
}

BuildReport is what a keyed build action reported, kept with the state the action committed so that a replay answers with it unchanged (decision 0043, "Replay for keyed operations"): the runs a delete removed, or a promotion's messages. A replay cannot rebuild either from the runs, which a delete removed and a promotion's file moves changed. It holds build names, numbers, paths and message text, never a credential, and it is kept a little longer than the replay's receipt, until Expires.

type BuildRetention

type BuildRetention struct {
	ProjectKey string
	Name       string
	// Count keeps at most this many runs; zero keeps every run.
	Count int
	// MinimumBuildDate discards runs started before it; zero keeps them.
	MinimumBuildDate time.Time
	DeleteArtifacts  bool
	// KeepNumbers are build numbers never discarded.
	KeepNumbers []string
}

BuildRetention is retention settings: which runs of a build name to keep. The store keeps, per build name, the settings of the latest build-info document that carried a buildRetention; that publish applied them, and later ones without settings discard nothing, as in Artifactory.

type BuildRun

type BuildRun struct {
	ID         int64
	ProjectKey string
	Name       string
	Number     string
	Started    time.Time
	Created    time.Time
}

BuildRun is one run's identity and timestamps, as listings return it.

type CreatedOrder

type CreatedOrder struct{}

CreatedOrder orders by creation time, then by version string so the order is total. Docker, OCI and Helm OCI tags carry no ordering of their own; Artifactory sorts them by manifest timestamp, which Max Unique Tags removes the oldest of.

func (CreatedOrder) Compare

func (CreatedOrder) Compare(a, b PackageVersion) int

Compare orders by Created, falling back to the tag name.

type FolderDownloadSettings

type FolderDownloadSettings struct {
	Enabled             bool `json:"enabled"`
	EnabledForAnonymous bool `json:"enabled_for_anonymous"`
	MaxDownloadSizeMB   int  `json:"max_download_size_mb"`
	MaxFiles            int  `json:"max_files"`
}

FolderDownloadSettings gate downloading a folder as one archive. As in Artifactory, it is off until enabled, and anonymous callers need their own switch.

type GitLFSLock

type GitLFSLock struct {
	ID       string
	RepoKey  string
	Path     string
	Owner    string
	LockedAt time.Time
}

GitLFSLock reserves a Git worktree path in one Git LFS repository. It is independent of the content-addressed LFS object index.

type Item

type Item struct {
	ID         int64            `json:"id"`
	RepoKey    string           `json:"repo_key"`
	Path       string           `json:"path"`
	Name       string           `json:"name"`
	Depth      int              `json:"depth"`
	Folder     bool             `json:"folder"`
	Cached     bool             `json:"cached"`
	Size       int64            `json:"size"`
	Actual     kernel.Checksums `json:"actual"`
	Original   kernel.Checksums `json:"original"`
	MimeType   string           `json:"mime_type,omitempty"`
	Created    time.Time        `json:"created"`
	CreatedBy  string           `json:"created_by,omitempty"`
	Modified   time.Time        `json:"modified"`
	ModifiedBy string           `json:"modified_by,omitempty"`
	Updated    time.Time        `json:"updated"`
	RemoteURL  string           `json:"remote_url,omitempty"`

	PropertiesModified time.Time `json:"properties_modified,omitzero"`
}

Item is one file or folder in the canonical form of decision 0004. Path is the parent folder ("." at the root), Name the last segment, and Depth the number of segments in the full path, so an item at the root has depth 1. Cached items belong to a remote repository's cache and are reported under RepoKey plus CacheSuffix. Actual holds what the server computed; Original holds what the client declared at deploy time, so a mismatch stays visible to the bad-checksum search. The type is persisted as part of the trash record, hence the tags.

PropertiesModified is when the item's properties last changed, zero while it has none; the storage API lists it as mdTimestamps.properties. Only the property methods of port.ItemStore set it. Put keeps the stored value whatever the caller passes, so a trash record or a copied item cannot carry another item's time onto the one written.

func RootItem

func RootItem(repoKey string, cached bool) Item

RootItem is the record of a repository root, which holds the properties set on the repository itself. AQL reports a root with "." as both its path and its name and a depth of 0, so the record is stored that way; no other item can be named ".", because SplitItemPath refuses the segment.

func (Item) FullPath

func (i Item) FullPath() string

FullPath is the item's path inside its repository without a leading slash, "" for a repository root.

func (Item) IsRoot

func (i Item) IsRoot() bool

IsRoot reports whether i is a repository root's record (RootItem).

func (Item) ReportedRepoKey

func (i Item) ReportedRepoKey() string

ReportedRepoKey is the repository key clients see for the item: the cache alias for cached items (decision 0007).

func (Item) StoragePath

func (i Item) StoragePath() string

StoragePath is the path as the storage API prints it, with a leading slash.

type ItemStats

type ItemStats struct {
	DownloadCount          int64     `json:"download_count"`
	LastDownloaded         time.Time `json:"last_downloaded"`
	LastDownloadedBy       string    `json:"last_downloaded_by,omitempty"`
	RemoteDownloadCount    int64     `json:"remote_download_count"`
	RemoteLastDownloaded   time.Time `json:"remote_last_downloaded"`
	RemoteLastDownloadedBy string    `json:"remote_last_downloaded_by,omitempty"`
	RemoteOrigin           string    `json:"remote_origin,omitempty"`
	RemotePath             string    `json:"remote_path,omitempty"`
}

ItemStats are an item's download statistics. They change out of band of the item record (every download updates them), so they live in their own table.

type KeypairRole

type KeypairRole string

KeypairRole is how a repository uses a key pair: the primary key signs metadata, the secondary is published for clients rotating to it.

const (
	KeypairPrimary   KeypairRole = "primary"
	KeypairSecondary KeypairRole = "secondary"
)

Key pair roles.

type Matrix

type Matrix struct {
	Props     Properties
	Mandatory map[string]bool
}

Matrix is a download's matrix parameters: the values asked for per key, and the keys sent as "key+=value", which the item must carry.

func (Matrix) Matches

func (m Matrix) Matches(props Properties) bool

Matches reports whether a file carrying props serves a download that asks for m: a key the file carries must have one of the values asked for, and a mandatory key must be carried. A key the file lacks does not stop a match otherwise.

type Package

type Package struct {
	ID      int64
	RepoKey string
	Type    repo.PackageType
	Name    string
	Created time.Time
}

Package is one name in one repository's package index (decision 0018). The pair (RepoKey, Name) is unique; Type is copied from the repository so the index can be queried without a join.

type PackageVersion

type PackageVersion struct {
	ID             int64
	PackageID      int64
	Version        string
	OrderKey       int64
	Created        time.Time
	LastDownloaded time.Time
	Metadata       []byte
}

PackageVersion is one version of a package. OrderKey is the version's rank under the package type's comparator, recomputed by the store whenever the package's version set changes, so SQL can sort and window (keepLastNVersions) without reimplementing every comparator in two dialects. Metadata is the format handler's per-version document (a packument fragment, a nuspec summary, a chart entry) and is opaque here.

type Properties

type Properties map[string][]string

Properties are an item's multi-valued properties. Values are kept sorted and unique so listings and comparisons are deterministic.

func (Properties) Add

func (p Properties) Add(key string, values ...string)

Add adds values to key, keeping existing ones.

func (Properties) Clone

func (p Properties) Clone() Properties

Clone returns a deep copy.

func (Properties) Equal

func (p Properties) Equal(o Properties) bool

Equal reports whether p and o hold the same keys with the same values in the same order; nil and empty are equal. Values in the order Set keeps them compare as sets.

func (Properties) Has

func (p Properties) Has(key, value string) bool

Has reports whether key carries value; an empty value matches any value, which is how property search treats a key given without a value.

func (Properties) Keys

func (p Properties) Keys() []string

Keys returns the keys in sorted order.

func (Properties) Set

func (p Properties) Set(key string, values ...string)

Set replaces the values of key.

type RemoteCacheEntry

type RemoteCacheEntry struct {
	// Smart belongs to this exact item/source/credential revision. Raw upstream
	// properties are independent of locally edited annotations and byte TTLs.
	Smart *RemoteSmartState `json:"smart,omitempty"`
	// MetadataBaseURL is private retrieval state for resolving relative links.
	// It must not include userinfo, query or fragment, or become a response header.
	MetadataBaseURL string `json:"metadata_base_url,omitempty"`
	// OriginalChecksums retains unverified upstream claims for pass-thru delivery.
	// Blob.Checksums always identifies the bytes actually ingested.
	OriginalChecksums kernel.Checksums `json:"original_checksums,omitempty"`
	Token             RemoteCacheToken `json:"token"`
	Kind              RemoteKind       `json:"kind"`
	ItemID            int64            `json:"item_id"`
	Blob              blob.Blob        `json:"blob"`
	ETag              string           `json:"etag"`
	LastModified      string           `json:"last_modified"`
	ContentType       string           `json:"content_type"`
	CacheControl      string           `json:"cache_control"`
	Vary              string           `json:"vary"`
	FetchedAt         time.Time        `json:"fetched_at"`
	ValidatedAt       time.Time        `json:"validated_at"`
	LastUsed          time.Time        `json:"last_used"`
	NegativeUntil     time.Time        `json:"negative_until"`
}

RemoteCacheEntry records retrieval state independently of Item.Updated. ItemID names an ingested artifact. Raw metadata instead owns Blob directly, outside the item tree, so a format reindex cannot overwrite the upstream list. An entry can keep its positive content while NegativeUntil records a later 404.

type RemoteCacheKey

type RemoteCacheKey struct {
	RepoKey          string `json:"repo_key"`
	Path             string `json:"path"`
	Variant          string `json:"variant"`
	SettingsRevision string `json:"settings_revision"`
}

RemoteCacheKey identifies one raw upstream representation. Variant and SettingsRevision are opaque non-secret identifiers, never raw signed queries.

type RemoteCacheToken

type RemoteCacheToken struct {
	PolicyRevision int64          `json:"policy_revision"`
	Key            RemoteCacheKey `json:"key"`
	Source         SourceIdentity `json:"source"`
	Epoch          int64          `json:"epoch"`
	Revision       int64          `json:"revision"`
}

RemoteCacheToken fences a fetch started outside the transaction. Epoch survives deletion of a cached path; Revision serializes competing completions.

type RemoteKind

type RemoteKind string

RemoteKind distinguishes freshness from the metadata-only zap policy.

const (
	RemoteUnique   RemoteKind = "unique"
	RemoteMutable  RemoteKind = "mutable"
	RemoteMetadata RemoteKind = "metadata"
	RemoteDerived  RemoteKind = "derived"
)

Remote cache representation kinds. Mutable payloads expire but are not zapped.

type RemoteSmartPeer

type RemoteSmartPeer struct {
	BaseURL    string    `json:"base_url"`
	Repository string    `json:"repository"`
	Class      string    `json:"class"`
	Version    string    `json:"version"`
	CheckedAt  time.Time `json:"checked_at"`
}

RemoteSmartPeer retains only sanitized discovery evidence, never the remote repository configuration (which may contain credentials or private URLs).

type RemoteSmartState

type RemoteSmartState struct {
	OwnedProperties Properties      `json:"owned_properties,omitempty"`
	LocalProperties map[string]bool `json:"local_properties,omitempty"`
	PropertiesAt    time.Time       `json:"properties_at"`
	OriginAt        time.Time       `json:"origin_at"`
	OriginAbsent    bool            `json:"origin_absent"`
	Downloads       int64           `json:"downloads"`
	Claimed         int64           `json:"claimed"`
	Uncertain       int64           `json:"uncertain"`
	LastDownload    time.Time       `json:"last_download"`
	LastDownloadBy  string          `json:"last_download_by,omitempty"`
}

RemoteSmartState is additive private cache state, persisted in the existing cache document. A statistics claim is committed before its HTTP submission: counts in Uncertain are never retried without a peer idempotency contract.

type RemoteSourceState

type RemoteSourceState struct {
	Smart              *RemoteSmartPeer `json:"smart,omitempty"`
	SettingsRevision   string           `json:"settings_revision"`
	PolicyRevision     int64            `json:"policy_revision"`
	Source             SourceIdentity   `json:"source"`
	Revision           int64            `json:"revision"`
	ConnectionFailures int              `json:"connection_failures"`
	OfflineUntil       time.Time        `json:"offline_until"`
	RetryAfterUntil    time.Time        `json:"retry_after_until"`
}

RemoteSourceState is shared by paths of a source. Success/failure scheduling belongs to the remote policy; the store provides generation-fenced durability.

type RepositoryIncarnation

type RepositoryIncarnation string

RepositoryIncarnation identifies one lifetime of a repository. Deleting and recreating the same key must allocate a different identity.

type SourceGeneration

type SourceGeneration string

SourceGeneration is a durable opaque revision, advanced when the effective source, credentials or connection configuration changes. A configuration hash alone is insufficient: changing a source away and back cannot revive old work.

type SourceIdentity

type SourceIdentity struct {
	Kind       SourceKind            `json:"kind"`
	Repository RepositoryIncarnation `json:"repository"`
	ID         string                `json:"id"`
	Generation SourceGeneration      `json:"generation"`
}

SourceIdentity namespaces cache entries and in-flight retrievals independently of mutable repository names. ID is opaque and contains no URL or credentials. Project sources will bind it to the producer and owner-project incarnations.

type SourceKind

type SourceKind string

SourceKind selects how a remote resolves content; an internal project source must never be inferred from an HTTP URL pointing at this server.

const (
	// ExternalHTTP is an upstream reached over HTTP, the one kind the source
	// boundary reads from (docs/implementation/source-boundary.md).
	ExternalHTTP SourceKind = "external-http"
	// ProjectRepository is a repository of another project on this instance,
	// which project sharing (P11) will read; until then a read of this kind
	// fails before any cache or network access.
	ProjectRepository SourceKind = "project-repository"
)

type StringComparator

type StringComparator func(a, b string) int

StringComparator adapts a comparison of version strings.

func (StringComparator) Compare

func (f StringComparator) Compare(a, b PackageVersion) int

Compare orders by the version string alone.

type TrashEntry

type TrashEntry struct {
	ID        int64
	Record    TrashRecord
	DeletedAt time.Time
	DeletedBy string
}

TrashEntry is one deleted item awaiting restore or purge.

func (TrashEntry) Expired

func (t TrashEntry) Expired(now time.Time, retention time.Duration) bool

Expired reports whether the entry is older than the retention period.

func (TrashEntry) TrashPath

func (t TrashEntry) TrashPath() string

TrashPath is where the entry sits in the trash can's tree: its original repository key, a slash and its original full path. The trash can's views list its tree in this path's byte order.

type TrashRecord

type TrashRecord struct {
	Item       Item       `json:"item"`
	Properties Properties `json:"properties,omitempty"`
	// PackageType is the package type of the repository the item was
	// deleted from, recorded then because the trash can still shows it once
	// that repository is gone, when it tells an administrator what type of
	// repository to recreate for a restore.
	PackageType string `json:"packageType,omitempty"` //nolint:tagliatelle // stored in trash records
}

TrashRecord is what the trash can keeps of a deleted item, as one JSON document, so a restore recreates the item and its properties exactly.

type TrashcanSettings

type TrashcanSettings struct {
	Enabled       bool `json:"enabled"`
	RetentionDays int  `json:"retention_days"`
}

TrashcanSettings control the trash can.

type VersionComparator

type VersionComparator interface {
	Compare(a, b PackageVersion) int
}

VersionComparator orders the versions of one package (decision 0018). Compare returns a negative number when a sorts before b, zero when they are equivalent and a positive number otherwise. Retention (keepLastNVersions), tag limits, "latest" resolution and the registration endpoints all sort through it, so one ecosystem never borrows another's rules.

func ComparatorFor

func ComparatorFor(t repo.PackageType) VersionComparator

ComparatorFor returns the comparator a package type sorts with. Types without a documented scheme (generic and the ecosystems artifactweave does not implement) use Maven ordering, which is what Artifactory's layout-based version search applies to any layout with a [baseRev] token.

type VersionFile

type VersionFile struct {
	VersionID int64
	ItemID    int64
}

VersionFile links a version to an item that belongs to it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL