Documentation
¶
Overview ¶
Package retention holds the per-ecosystem rules for evicting cached artifacts that have not been accessed for a configured time.
An ecosystem takes part only once its handler registers a Spec with Default, usually from an init function in the handler's own file. Until then configuring retention for it is a validation error, and the global default does not apply to it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = NewRegistry()
Default is the registry the handlers register with.
var KnownKeys = []string{
"alpine", "cargo", "composer", "conan", "conda", "cran", "deb", "gem",
"generic", "golang", "helm", "hex", "julia", "maven", "npm", "nuget", "oci", "pub",
"pypi", "rpm", "swift",
}
KnownKeys lists the ecosystem keys storage.retention.ecosystems accepts. They are the literals the handlers pass when they fetch an artifact. A key outside this list is a typo; a key in it whose handler has not registered yet is not supported by this version.
Functions ¶
func DefaultCanonical ¶
DefaultCanonical returns a CanonicalPackage for ecosystems that store the package PURL exactly as purl.MakePURLString builds it from the PURL's full name. It accepts a PURL only when building it back that way gives the same package, so for an ecosystem that stores a different form, such as one with a default namespace, it refuses the key instead of producing one that never matches. Such ecosystems need their own CanonicalPackage.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps ecosystem keys to their specs.
func (*Registry) Canonical ¶
Canonical returns the stored package PURL a configured package PURL stands for, asking the registered specs in key order.
func (*Registry) KeyForDBEcosystem ¶
KeyForDBEcosystem returns the registered key a packages.ecosystem value belongs to.
type Rules ¶
type Rules struct {
// Default applies to registered ecosystems without their own rule,
// except generic, which requires an explicit rule.
Default time.Duration
// Ecosystems holds rules keyed by registered ecosystem key.
Ecosystems map[string]time.Duration
// Packages holds rules keyed by the package PURL stored in the cache.
Packages map[string]time.Duration
}
Rules are resolved retention durations. A duration of zero means an artifact is never evicted by age.
func (Rules) For ¶
For returns the retention for an artifact of the given ecosystem key and stored package PURL: the package rule, else the ecosystem rule, else the default. Generic artifacts require an explicit package or ecosystem rule.
func (Rules) MinPositive ¶
MinPositive returns the shortest non-zero duration among all rules, or zero when every rule is zero.
type Spec ¶
type Spec struct {
// Key is the ecosystem's config key, one of KnownKeys.
Key string
// ExtraDBEcosystems lists packages.ecosystem values besides the ones
// derived from Key that belong to this ecosystem.
ExtraDBEcosystems []string
// CanonicalPackage turns a package PURL from the config into the
// package PURL the handler stores in the cache, reporting false when the
// PURL does not belong to this ecosystem. Nil means the ecosystem accepts
// no package overrides.
CanonicalPackage func(p *purl.PURL) (string, bool)
}
Spec describes how one ecosystem takes part in retention.