Documentation
¶
Overview ¶
Package model holds the releases module's entity values: release bundles v1 with their specs, frozen artifact lists, retention marks and exports, and their distribution to edges through trackers, rules and per-target jobs.
Role ¶
releases module, core layer, entity values. The module's store ports take and return them, and P15's bundle and distribution services will build on them. The package imports the standard library and the kernel (the checksums of a bundle artifact). SigningKey, the key bundles are signed with, is not here: it is one of the access module's key records, which STO-10 moves.
Inputs ¶
- For SelectTargets, distribution rules and the targets they select from; for TrackerStatus, a tracker's jobs.
Outputs ¶
- ReleaseBundle with BundleState (with Editable) and BundleOrigin; BundleSpec with BundleQuery, PathMapping and PropertyValues; ReleaseNotes; BundleArtifact; BundleExport.
- BundleRetentionConfig, BundleRetentionAudit and BundleOperation.
- DistributionTracker with TrackerKind, DistributionJob, JobStatus with TrackerStatus, and DistributionTarget and DistributionRule with Matches and SelectTargets.
Invariants ¶
- Signing freezes a bundle version: only an OPEN bundle is Editable.
- Job statuses are Distribution's display strings, as jfrog-client-go and the archived REST examples show them (research 17), except Aborted, artifactweave's own, which no published example shows.
- A rule's empty fields match every target, and its site name takes '*' wildcards, as JFrog's rules do.
References ¶
- Decision 0023: docs/research/decisions/0023-release-bundles-and-distribution.md.
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence").
- Research 16: docs/research/16-enterprise-products.md. Research 17: docs/research/17-undocumented-shapes.md (bundle states and job statuses). Research 15: docs/research/15-data-model.md, lines 709 to 714 (the bundle and distribution tables) and line 760 (bundle retention as built).
- Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 100 to 103 (a storage skeleton ahead of its phase), lines 348 to 353 (the releases module), lines 577 and 578 (each module owns its store ports) and line 1058 (the shared types split into each module's core/model).
- Plan: docs/implementation/plan.md#p2-stores, task 0, #p15-release-bundles-v1-and-distribution and #p9d-modular-monolith-migration, epic STO (https://github.com/weaveplatform/artifactweave/issues/939).
- https://github.com/weaveplatform/artifactweave/issues/1053
Status ¶
Implemented P2: the release bundle and distribution values among the shared domain types (pull request 3). Moved here in P9d. The behaviour that uses them arrives with P15.
Testing ¶
- distribution_test.go: TestUnitDistribution (Editable, rule matching and target selection, and tracker status from its jobs).
The metadata store's Bundles, BundleRetention, BundleExports and Distribution contract subtests store and read these values on its in-memory, SQLite and PostgreSQL stores.
Index ¶
- type BundleArtifact
- type BundleExport
- type BundleOperation
- type BundleOrigin
- type BundleQuery
- type BundleRetentionAudit
- type BundleRetentionConfig
- type BundleSpec
- type BundleState
- type DistributionJob
- type DistributionRule
- type DistributionTarget
- type DistributionTracker
- type JobStatus
- type PathMapping
- type PropertyValues
- type ReleaseBundle
- type ReleaseNotes
- type TrackerKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BundleArtifact ¶
type BundleArtifact struct {
BundleName string
BundleVersion string
SourcePath string
TargetPath string
Checksums kernel.Checksums
Size int64
Props []PropertyValues
}
BundleArtifact is one frozen entry of a bundle's artifact list.
type BundleExport ¶
type BundleExport struct {
BundleName string
BundleVersion string
Status JobStatus
ArchiveSHA256 string
Created time.Time
}
BundleExport is an exported bundle archive.
type BundleOperation ¶
type BundleOperation string
BundleOperation is a retention audit operation.
const ( BundleDelete BundleOperation = "DELETE" BundleKeep BundleOperation = "KEEP" BundleUnkeep BundleOperation = "UNKEEP" )
Bundle retention operations.
type BundleOrigin ¶
type BundleOrigin string
BundleOrigin says whether this instance created the bundle or received it.
const ( BundleSource BundleOrigin = "source" BundleReceived BundleOrigin = "received" )
Bundle origins.
type BundleQuery ¶
type BundleQuery struct {
Name string `json:"name,omitempty"`
AQL string `json:"aql"`
Mappings []PathMapping `json:"mappings,omitempty"`
AddedProps []PropertyValues `json:"added_props,omitempty"`
ExcludePropsPatterns []string `json:"exclude_props_patterns,omitempty"`
}
BundleQuery selects artifacts for a bundle by AQL.
type BundleRetentionAudit ¶
type BundleRetentionAudit struct {
BundleName string
BundleVersion string
Operation BundleOperation
Created time.Time
CreatedBy string
}
BundleRetentionAudit records a keep mark change or a retention deletion.
type BundleRetentionConfig ¶
type BundleRetentionConfig struct {
Automatic bool `json:"automatic"`
VersionsToKeepPerBundle int `json:"versions_to_keep_per_bundle"`
MaxDaysToKeep int `json:"max_days_to_keep"`
CronPattern string `json:"cron_pattern,omitempty"`
MaxDeletionsPerBackgroundRun int `json:"max_deletions_per_background_run"`
Enabled bool `json:"enabled"`
}
BundleRetentionConfig is the release bundle v1 retention singleton.
type BundleSpec ¶
type BundleSpec struct {
Queries []BundleQuery `json:"queries"`
}
BundleSpec is the creation spec, kept as a document so the bundle records how it was built.
type BundleState ¶
type BundleState string
BundleState is a release bundle version's lifecycle state (decision 0023).
const ( BundleOpen BundleState = "OPEN" BundleSigned BundleState = "SIGNED" BundleStored BundleState = "STORED" )
Bundle states. OPEN and SIGNED are Distribution's documented values (research 17); STORED records that the signed version was also written to its storing repository, which Distribution reports through storing_repository rather than a state of its own.
func (BundleState) Editable ¶
func (s BundleState) Editable() bool
Editable reports whether the bundle can still be changed; signing freezes it.
type DistributionJob ¶
type DistributionJob struct {
TrackerID int64
PeerInstanceID string
Status JobStatus
Priority int
Started time.Time
Finished time.Time
Error string
}
DistributionJob is one tracker's work for one target, carried on its own peer stream.
type DistributionRule ¶
type DistributionRule struct {
SiteName string `json:"site_name,omitempty"`
CityName string `json:"city_name,omitempty"`
CountryCodes []string `json:"country_codes,omitempty"`
Priority int `json:"priority,omitempty"`
}
DistributionRule selects targets; empty fields match everything. SiteName accepts '*' wildcards as JFrog's rules do.
func (DistributionRule) Matches ¶
func (r DistributionRule) Matches(t DistributionTarget) bool
Matches reports whether t satisfies the rule.
type DistributionTarget ¶
type DistributionTarget struct {
PeerInstanceID string
SiteName string
CityName string
CountryCode string
}
DistributionTarget is an edge: a peer paired for distribution, with the location rules select on.
func SelectTargets ¶
func SelectTargets(rules []DistributionRule, targets []DistributionTarget) []DistributionTarget
SelectTargets returns the targets any rule matches, in target order.
type DistributionTracker ¶
type DistributionTracker struct {
ID int64
BundleName string
BundleVersion string
Kind TrackerKind
DryRun bool
AutoCreateMissingRepositories bool
Rules []DistributionRule
Status JobStatus
Created time.Time
CreatedBy string
}
DistributionTracker is one distribute or delete request (int64 id on the wire) with its selection rules.
type JobStatus ¶
type JobStatus string
JobStatus is the state of a tracker or of one per-target job. The strings are Distribution's display values as jfrog-client-go and the archived REST examples show them (research 17); Aborted is artifactweave's, reported after an abort request because no published example shows that state.
const ( JobNotDistributed JobStatus = "Not distributed" JobInQueue JobStatus = "In queue" JobInProgress JobStatus = "In progress" JobCompleted JobStatus = "Completed" JobFailed JobStatus = "Failed" JobAborted JobStatus = "Aborted" )
Job statuses.
func TrackerStatus ¶
func TrackerStatus(jobs []DistributionJob) JobStatus
TrackerStatus summarises job statuses: failed if any failed, in progress while any is running or queued, completed when all completed.
type PathMapping ¶
PathMapping rewrites a source path to a target path; Output may refer to capture groups of Input.
type PropertyValues ¶
PropertyValues is one key and its values in a bundle spec or artifact.
type ReleaseBundle ¶
type ReleaseBundle struct {
Name string
Version string
Description string
Notes ReleaseNotes
StoringRepository string
State BundleState
Spec BundleSpec
ProjectKey string
Origin BundleOrigin
Created time.Time
CreatedBy string
SignedAt time.Time
SigningKeyAlias string
Signature []byte
}
ReleaseBundle is one version of a release bundle v1.
type ReleaseNotes ¶
type ReleaseNotes struct {
Syntax string `json:"syntax,omitempty"`
Content string `json:"content,omitempty"`
}
ReleaseNotes accompany a bundle version.
type TrackerKind ¶
type TrackerKind string
TrackerKind is what a distribution tracker does.
const ( TrackerDistribute TrackerKind = "distribute" TrackerDelete TrackerKind = "delete" )
Tracker kinds.