Documentation
¶
Overview ¶
Package service answers strata's questions over an index: what an image is, where it came from, what is built on it, and whether it is stale. The CLI, the HTTP API and the MCP server all call it, so every interface gives the same answers.
Index ¶
- Constants
- Variables
- func IsInputError(err error) bool
- func NormalizeKey(k string) string
- type BaseCluster
- type BaseVersion
- type BuiltFrom
- type Change
- type Cleanup
- type CleanupCandidate
- type CleanupOptions
- type CleanupRepo
- type ConfigInfo
- type DescendantOptions
- type DescendantResult
- type Diff
- type Explanation
- type Facet
- type FacetValue
- type GroupMetrics
- type ImageInfo
- type IndexResult
- type IndexStatus
- type InputError
- type LabelDetail
- type LabelKey
- type LayerInfo
- type LayerStat
- type Lifecycle
- type LifecycleAction
- type LifecycleConflict
- type LifecycleOptions
- type LifecyclePolicy
- type LifecycleRule
- type LifecycleSelection
- type LineageInfo
- type Outline
- type OutlineRow
- type Overview
- type Point
- type QueryOptions
- type RefreshStats
- type Root
- type RootStat
- type SearchHit
- type SearchOptions
- type SearchResult
- type Service
- func (s *Service) Ancestry(ctx context.Context, ref, platform string) (*graph.Graph, error)
- func (s *Service) Bloat(ctx context.Context, perRepo bool, minSize int64, limit int) ([]LayerStat, error)
- func (s *Service) Cleanup(ctx context.Context, opts CleanupOptions) (*Cleanup, error)
- func (s *Service) Descendants(ctx context.Context, ref string, opts DescendantOptions) (*DescendantResult, error)
- func (s *Service) Diff(ctx context.Context, since time.Duration, groupBy string, darkDays int) (*Diff, error)
- func (s *Service) Explain(ctx context.Context, ref, platform string, history bool) (*Explanation, error)
- func (s *Service) Index(ctx context.Context, opts crawl.Options) (res IndexResult, err error)
- func (s *Service) Label(ctx context.Context, key string) (*LabelDetail, error)
- func (s *Service) Labels(ctx context.Context) ([]LabelKey, error)
- func (s *Service) Lifecycles(ctx context.Context, opts LifecycleOptions) ([]Lifecycle, error)
- func (s *Service) Map(ctx context.Context, depth int) ([]OutlineRow, error)
- func (s *Service) NeedsRefresh(ctx context.Context) (bool, error)
- func (s *Service) Outline(ctx context.Context, parent string, onlyStale bool, offset, limit int) (*Outline, error)
- func (s *Service) Overview(ctx context.Context) (*Overview, error)
- func (s *Service) Query(ctx context.Context, opts QueryOptions) (*Table, error)
- func (s *Service) QueryEach(ctx context.Context, opts QueryOptions, header func([]string) error, ...) error
- func (s *Service) QueryGraph(ctx context.Context, filter string, budget int) (*graph.Graph, error)
- func (s *Service) Refresh(ctx context.Context) error
- func (s *Service) Resolve(ctx context.Context, ref, platform string) (string, error)
- func (s *Service) Roots(ctx context.Context) ([]Root, error)
- func (s *Service) RootsGraph(ctx context.Context) (*graph.Graph, error)
- func (s *Service) Search(ctx context.Context, o SearchOptions) (*SearchResult, error)
- func (s *Service) SimilarBases(ctx context.Context) ([]BaseCluster, error)
- func (s *Service) SimilarKeys(ctx context.Context) ([][]string, error)
- func (s *Service) Snapshot(ctx context.Context) error
- func (s *Service) Stale(ctx context.Context, groupBy string) (*Table, error)
- func (s *Service) Status() IndexStatus
- func (s *Service) Summary(ctx context.Context, groupBy string) (*Summary, error)
- func (s *Service) TopLayers(ctx context.Context, by string, limit int) ([]LayerStat, error)
- func (s *Service) Trend(ctx context.Context, metric, groupBy string) ([]Point, error)
- type StalenessInfo
- type Summary
- type Table
- type VerdictCounts
Constants ¶
const ( // ScopeRegistry counts a layer as freed only when no kept image in // any repo uses it, as for a registry that stores each blob once. ScopeRegistry = "registry" // ScopeRepo counts a layer as freed when no kept image in the same // repo uses it, as for a registry that stores blobs per repository. ScopeRepo = "repo" )
Cleanup scopes: which images' layers count as kept when working out what deleting the candidates frees.
const DefaultCleanupFilter = `stale = "abandoned"`
DefaultCleanupFilter selects deletion candidates when none is given: images the staleness policy calls abandoned, which are untagged, have nothing built on them and have not been pulled in the policy's window.
const ( // Unrooted is the pseudo-root holding images with no known parent and // nothing built on them. Unrooted = "unrooted" )
Outline row kinds and ids.
Variables ¶
var CleanupColumns = []string{"repo", "digest", "images", "size", "exclusive_bytes", "verdict", "pushed_days", "last_pulled_days", "reason"}
CleanupColumns are the columns of a candidate export, in order.
var DefaultFields = []string{"repo", "tag", "digest", "platform", "created", "size", "stale"}
DefaultFields are the columns a query returns when none are asked for.
var ErrNotFound = errors.New("not found in the index")
ErrNotFound is returned when a ref matches no indexed image.
var SnapshotGroups = []string{"repo", "root"}
SnapshotGroups are the groupings recorded every day, besides the total.
Functions ¶
func IsInputError ¶
IsInputError reports whether err was caused by the caller's input.
func NormalizeKey ¶
NormalizeKey folds case and drops separators, so team, Team, TEAM and t-e_a.m compare equal; a trailing name or id suffix is dropped too (team_name, team-id).
Types ¶
type BaseCluster ¶
type BaseCluster struct {
Bases []string `json:"bases"`
Descendants int64 `json:"descendants"`
// SavedBytes estimates the deduplicated bytes saved by standardizing
// on one base: the size of the differing top layers of all but the
// largest base.
SavedBytes int64 `json:"saved_bytes"`
}
BaseCluster is a group of bases whose stacks match except for their last one or two layers.
type BaseVersion ¶
type BaseVersion struct {
Digest string `json:"digest"`
Label string `json:"label"`
Source string `json:"source"`
Confidence string `json:"confidence"`
Current bool `json:"current"`
Children int `json:"children"`
Descendants int `json:"descendants"`
}
BaseVersion is one digest a base tag has pointed to, and how much is built on it.
type BuiltFrom ¶ added in v0.3.1
type BuiltFrom struct {
Ref string `json:"ref"`
Digest string `json:"digest,omitempty"`
// Status is parent (the image is built on it), stage (indexed, but
// another build stage's image: the image does not start with its
// layers), missing (strata could not fetch it; Reason says why) or
// pending (the next index fetches it).
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
BuiltFrom is one image a build pulled, by its provenance.
type Change ¶
type Change struct {
Kind string `json:"kind"`
Group string `json:"group"`
Metric string `json:"metric,omitempty"`
From float64 `json:"from"`
To float64 `json:"to"`
}
Change is one line of a diff report.
type Cleanup ¶ added in v0.3.0
type Cleanup struct {
Where string `json:"where"`
Scope string `json:"scope"`
// Candidates are ordered by exclusive bytes, largest first.
Candidates []CleanupCandidate `json:"candidates"`
// Repos are ordered by reclaimable bytes; RepoCount counts every repo
// with candidates.
Repos []CleanupRepo `json:"repos"`
RepoCount int `json:"repo_count"`
// Total counts candidates; Images counts their platform images.
Total int `json:"total"`
Images int `json:"images"`
// Size is the sum of the candidates' stated sizes, which counts a
// shared layer once per image; Reclaimable counts each freed layer
// once, and leaves out layers a kept image still uses.
Size int64 `json:"size"`
Reclaimable int64 `json:"reclaimable_bytes"`
// Held counts images that matched but are kept: other images are
// built on them, or they share an index with images that are kept.
Held int `json:"held"`
}
Cleanup is the list of deletion candidates and what deleting them all frees.
type CleanupCandidate ¶ added in v0.3.0
type CleanupCandidate struct {
// Digest is what to delete: the manifest, or the index.
Digest string `json:"digest"`
Repo string `json:"repo"`
// Images counts the platform images it holds; 1 for a manifest.
Images int `json:"images"`
// Size is the compressed size its manifests state.
Size int64 `json:"size"`
// Exclusive is what deleting only this candidate frees: layers no
// other image in scope uses, candidates included.
Exclusive int64 `json:"exclusive_bytes"`
Verdict string `json:"verdict"`
Reason string `json:"reason"`
PushedDays *int `json:"pushed_days"`
LastPulledDays *int `json:"last_pulled_days"`
}
CleanupCandidate is one manifest, or one multi-platform index with its platform images, that can be deleted.
func (CleanupCandidate) Row ¶ added in v0.3.0
func (c CleanupCandidate) Row() []any
Row returns the candidate as values in CleanupColumns order.
type CleanupOptions ¶ added in v0.3.0
type CleanupOptions struct {
// Where selects candidates with the query language; empty means
// DefaultCleanupFilter.
Where string
// Scope is ScopeRegistry (the default) or ScopeRepo.
Scope string
// Limit caps the candidates and the repos listed; totals count them
// all. Zero lists them all.
Limit int
}
CleanupOptions pick deletion candidates.
type CleanupRepo ¶ added in v0.3.0
type CleanupRepo struct {
Repo string `json:"repo"`
Candidates int `json:"candidates"`
Size int64 `json:"size"`
Reclaimable int64 `json:"reclaimable_bytes"`
}
CleanupRepo totals the candidates of one repo.
type ConfigInfo ¶
type ConfigInfo struct {
User string `json:"user"`
Entrypoint []string `json:"entrypoint"`
Cmd []string `json:"cmd"`
Ports []string `json:"ports"`
EnvKeys []string `json:"env_keys"`
EnvValues map[string]string `json:"env_values,omitempty"`
Workdir string `json:"workdir"`
StopSignal string `json:"stop_signal"`
Healthcheck bool `json:"healthcheck"`
}
ConfigInfo holds the run-time fields from the image config.
type DescendantOptions ¶
type DescendantOptions struct {
Platform string
// Depth limits levels below the base; 0 means the whole subtree.
Depth int
// AllVersions widens the base to every digest its tag has held.
AllVersions bool
// VersionsFrom is a file listing more base digests or refs, one per
// line.
VersionsFrom string
// Budget caps graph nodes; 0 means graph.DefaultBudget.
Budget int
}
DescendantOptions control a descendant walk.
type DescendantResult ¶
type DescendantResult struct {
Graph *graph.Graph `json:"graph"`
Versions []BaseVersion `json:"versions"`
// Images counts every descendant before the graph budget applied.
Images int `json:"images"`
}
DescendantResult is a descendant graph and the base versions it starts from.
type Diff ¶
type Diff struct {
From string `json:"from"`
To string `json:"to"`
Changes []Change `json:"changes"`
DarkRepos []string `json:"dark_repos"`
}
Diff is what changed between two snapshots.
type Explanation ¶
type Explanation struct {
Image ImageInfo `json:"image"`
Lineage LineageInfo `json:"lineage"`
Staleness StalenessInfo `json:"staleness"`
Layers []LayerInfo `json:"layers"`
History []model.HistoryEntry `json:"history,omitempty"`
Referrers []model.Referrer `json:"referrers"`
Findings []string `json:"findings"`
}
Explanation answers "what is this image, and where did it come from?".
type Facet ¶
type Facet struct {
Name string `json:"name"`
Field string `json:"field"`
Values []FacetValue `json:"values"`
}
Facet is a field the search can be narrowed by.
type FacetValue ¶
type FacetValue struct {
Value string `json:"value"`
Count int64 `json:"count"`
Selected bool `json:"selected"`
}
FacetValue is one value of a facet.
type GroupMetrics ¶
type GroupMetrics struct {
Group string `json:"group"`
Repos int64 `json:"repos"`
Tags int64 `json:"tags"`
Manifests int64 `json:"manifests"`
Stacks int64 `json:"unique_stacks"`
UntaggedPct float64 `json:"untagged_pct"`
ApparentBytes int64 `json:"apparent_bytes"`
DedupBytes int64 `json:"dedup_bytes"`
ExclusiveBytes int64 `json:"exclusive_bytes"`
Fresh int64 `json:"fresh"`
Drifting int64 `json:"drifting"`
Stale int64 `json:"stale"`
Abandoned int64 `json:"abandoned"`
}
GroupMetrics are the footprint numbers for one group of images.
type ImageInfo ¶
type ImageInfo struct {
Digest string `json:"digest"`
Repo string `json:"repo"`
Label string `json:"label"`
Tags []string `json:"tags"`
IndexDigest string `json:"index_digest,omitempty"`
Platform string `json:"platform"`
Platforms []string `json:"platforms,omitempty"`
Created *time.Time `json:"created,omitempty"`
AgeDays *int `json:"age_days,omitempty"`
// Pushed is when the registry says the image was first pushed (ECR);
// FirstSeen is when strata first indexed it.
Pushed *time.Time `json:"pushed,omitempty"`
FirstSeen *time.Time `json:"first_seen,omitempty"`
Size int64 `json:"size"`
LayerCount int `json:"layer_count"`
TopChainID string `json:"top_chain_id"`
External bool `json:"external"`
Labels map[string]string `json:"labels"`
Config ConfigInfo `json:"config"`
}
ImageInfo is what the index knows about one image.
type IndexResult ¶
type IndexResult struct {
Crawl crawl.Stats `json:"crawl"`
Images int64 `json:"images"`
Duration time.Duration `json:"duration"`
}
IndexResult reports what an index run did.
type IndexStatus ¶ added in v0.2.0
type IndexStatus struct {
// Running is whether a crawl is in progress.
Running bool `json:"running"`
// Registry is the registry being or last crawled.
Registry string `json:"registry,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
// RefreshedAt is when lineage, staleness and the views were last
// recomputed; results in the UI are as of then. It is unset until the
// first refresh of the index finishes, and lineage, staleness and the
// registry map are empty until then.
RefreshedAt *time.Time `json:"refreshed_at,omitempty"`
// Refreshing is whether a refresh is running now.
Refreshing bool `json:"refreshing"`
// RefreshEverySeconds is how often views refresh while a crawl runs;
// zero means only when it finishes.
RefreshEverySeconds int64 `json:"refresh_every_seconds"`
// Crawl holds the running totals.
Crawl crawl.Stats `json:"crawl"`
// LastRefresh says what the last refresh rewrote and how long it took.
LastRefresh *RefreshStats `json:"last_refresh,omitempty"`
// Error is why the last index failed.
Error string `json:"error,omitempty"`
// RefreshError is why the last refresh failed, so the UI can say so
// instead of waiting for views that will not come; a refresh that
// succeeds clears it.
RefreshError string `json:"refresh_error,omitempty"`
}
IndexStatus is the state of the running index, or of the last one.
type InputError ¶
type InputError struct{ Err error }
InputError marks an error caused by the caller's input, such as a filter syntax error or an unknown field, as opposed to a failure of the index. The API answers it with 400.
type LabelDetail ¶
type LabelDetail struct {
Key string `json:"key"`
Values map[string]int64 `json:"values"`
Lacking map[string]int64 `json:"repos_lacking"`
FirstSeen *time.Time `json:"first_seen,omitempty"`
LastSeen *time.Time `json:"last_seen,omitempty"`
Images int64 `json:"images"`
Kind string `json:"kind"`
}
LabelDetail describes one key: its values, the repos lacking it and when it was first and last seen.
type LabelKey ¶
type LabelKey struct {
Key string `json:"key"`
Images int64 `json:"images"`
CoveragePct float64 `json:"coverage_pct"`
Distinct int64 `json:"distinct_values"`
TopValues []string `json:"top_values"`
Required bool `json:"required,omitempty"`
}
LabelKey profiles one label or annotation key.
type LayerInfo ¶
type LayerInfo struct {
Position int `json:"position"`
DiffID string `json:"diff_id"`
BlobDigest string `json:"blob_digest"`
Size int64 `json:"size"`
CreatedBy string `json:"created_by"`
SharedBy int `json:"shared_by"`
}
LayerInfo is one layer and the build step that made it.
type LayerStat ¶
type LayerStat struct {
DiffID string `json:"diff_id"`
Blob string `json:"blob_digest"`
Size int64 `json:"size"`
Images int64 `json:"images"`
Repos int64 `json:"repos"`
CreatedBy string `json:"created_by"`
Example string `json:"example_repo"`
}
LayerStat is one layer blob and how it is used.
type Lifecycle ¶ added in v0.3.0
type Lifecycle struct {
Repo string `json:"repo"`
// Name is the repository name ECR knows it by, without the host.
Name string `json:"name"`
Days int `json:"days"`
// Expires counts the images the rule would expire today; Agree counts
// those strata also lists for cleanup.
Expires int `json:"expires"`
Agree int `json:"agree"`
// Conflicts are images the rule would expire that strata keeps, with
// why; a repo with conflicts gets no policy unless asked.
Conflicts []LifecycleConflict `json:"conflicts"`
// Policy is the lifecycle policy document, or nil when the repo is
// skipped.
Policy *LifecyclePolicy `json:"policy"`
// Skipped says why the repo has no policy.
Skipped string `json:"skipped,omitempty"`
}
Lifecycle is a generated ECR lifecycle policy for one repo, checked against the index.
type LifecycleAction ¶ added in v0.3.0
type LifecycleAction struct {
Type string `json:"type"`
}
LifecycleAction is what a rule does.
type LifecycleConflict ¶ added in v0.3.0
LifecycleConflict is an image a rule would expire that strata keeps.
type LifecycleOptions ¶ added in v0.3.0
type LifecycleOptions struct {
// Repos limits the repos, as globs over the repo name with its host.
Repos []string
// Days overrides the age untagged images expire at; zero uses each
// repo's abandoned_pull_days from the staleness policy.
Days int
// IncludeConflicts keeps a repo's rule even when it would expire
// images strata keeps.
IncludeConflicts bool
}
LifecycleOptions shape generated ECR lifecycle policies.
type LifecyclePolicy ¶ added in v0.3.0
type LifecyclePolicy struct {
Rules []LifecycleRule `json:"rules"`
}
LifecyclePolicy is an ECR lifecycle policy document.
func (*LifecyclePolicy) Text ¶ added in v0.3.0
func (p *LifecyclePolicy) Text() string
Text returns the policy as the JSON put-lifecycle-policy takes.
type LifecycleRule ¶ added in v0.3.0
type LifecycleRule struct {
RulePriority int `json:"rulePriority"`
Description string `json:"description"`
Selection LifecycleSelection `json:"selection"`
Action LifecycleAction `json:"action"`
}
LifecycleRule is one rule of an ECR lifecycle policy.
type LifecycleSelection ¶ added in v0.3.0
type LifecycleSelection struct {
TagStatus string `json:"tagStatus"`
CountType string `json:"countType"`
CountUnit string `json:"countUnit,omitempty"`
CountNumber int `json:"countNumber"`
}
LifecycleSelection picks the images a rule applies to.
type LineageInfo ¶
type LineageInfo struct {
Status string `json:"status"`
Parent string `json:"parent,omitempty"`
Root string `json:"root,omitempty"`
Generation int `json:"generation"`
Children int `json:"children"`
Descendants int `json:"descendants"`
Conflict bool `json:"conflict"`
Edges []graph.Edge `json:"edges"`
// BuiltFrom are the images the build's provenance says it pulled,
// with whether each is indexed, so a missing parent can be explained.
BuiltFrom []BuiltFrom `json:"built_from,omitempty"`
Ancestry *graph.Graph `json:"ancestry"`
}
LineageInfo summarizes where an image sits in the graph.
type Outline ¶
type Outline struct {
Parent string `json:"parent,omitempty"`
Rows []OutlineRow `json:"rows"`
Total int64 `json:"total"`
Offset int `json:"offset"`
}
Outline is one page of an outline row's children.
type OutlineRow ¶
type OutlineRow struct {
ID string `json:"id"`
Parent string `json:"parent,omitempty"`
Kind string `json:"kind"`
Name string `json:"name"`
Repo string `json:"repo,omitempty"`
Team string `json:"team,omitempty"`
Digest string `json:"digest,omitempty"`
Tags []string `json:"tags,omitempty"`
Verdict string `json:"verdict,omitempty"`
Images int64 `json:"images"`
Verdicts VerdictCounts `json:"verdicts"`
Drift int `json:"drift,omitempty"`
Newest *time.Time `json:"newest,omitempty"`
HasChildren bool `json:"has_children"`
Depth int `json:"depth"`
}
OutlineRow is one row of the lineage outline: a base, a repo group or an image.
type Overview ¶
type Overview struct {
Host string `json:"host,omitempty"`
Images int64 `json:"images"`
Repos int64 `json:"repos"`
Tags int64 `json:"tags"`
Stacks int64 `json:"stacks"`
ApparentBytes int64 `json:"apparent_bytes"`
DedupBytes int64 `json:"dedup_bytes"`
Verdicts VerdictCounts `json:"verdicts"`
Roots []RootStat `json:"roots"`
Changes []Change `json:"changes"`
IndexedAt *time.Time `json:"indexed_at,omitempty"`
}
Overview is the headline view of the index.
type Point ¶
type Point struct {
Day string `json:"day"`
Group string `json:"group"`
Value float64 `json:"value"`
}
Point is one day's value of a metric.
type QueryOptions ¶
type QueryOptions struct {
Filter string
// Fields are the columns to return; empty means DefaultFields.
Fields []string
// Sort lists fields to order by; a leading - sorts descending.
Sort []string
// Limit caps rows; 0 means no limit.
Limit int
// GroupBy counts images per value of a field instead of listing them.
GroupBy string
}
QueryOptions shape a filter query's output.
type RefreshStats ¶ added in v0.2.1
type RefreshStats struct {
// Full is true when every derived table was rebuilt: the first
// refresh, or one after the image_facts layout changed.
Full bool `json:"full"`
// LineageSkipped is true when no input to lineage changed.
LineageSkipped bool `json:"lineage_skipped"`
// LineageChanged, VerdictsChanged and FactsRebuilt count the rows each
// step rewrote.
LineageChanged int `json:"lineage_changed"`
VerdictsChanged int `json:"verdicts_changed"`
FactsRebuilt int `json:"facts_rebuilt"`
// SnapshotRows counts today's snapshot rows added, changed or removed;
// SnapshotSkipped is true when no image row changed since today's.
SnapshotRows int `json:"snapshot_rows"`
SnapshotSkipped bool `json:"snapshot_skipped"`
Duration time.Duration `json:"duration"`
}
RefreshStats reports what a refresh did, so its cost can be traced to what changed.
type Root ¶
type Root struct {
ID string `json:"id"`
Label string `json:"label"`
Kind string `json:"kind"`
Children int `json:"children"`
Descendants int `json:"descendants"`
StalePct float64 `json:"stale_pct"`
}
Root is one root base and how much is built on it.
type RootStat ¶
type RootStat struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Images int64 `json:"images"`
Verdicts VerdictCounts `json:"verdicts"`
}
RootStat is a root base and the verdicts of everything built on it.
type SearchHit ¶
type SearchHit struct {
Digest string `json:"digest"`
Repo string `json:"repo"`
Name string `json:"name"`
Tags []string `json:"tags"`
Team string `json:"team,omitempty"`
Root string `json:"root,omitempty"`
Platform string `json:"platform"`
Verdict string `json:"verdict"`
AgeDays *int `json:"age_days,omitempty"`
Size int64 `json:"size"`
}
SearchHit is one image in search results.
type SearchOptions ¶
type SearchOptions struct {
Filter string
Team []string
Root []string
Verdict []string
Platform []string
Age []string
Pushed []string
Offset int
Limit int
}
SearchOptions are a filter plus facet selections.
type SearchResult ¶
type SearchResult struct {
Total int64 `json:"total"`
Offset int `json:"offset"`
Filter string `json:"filter"`
Hits []SearchHit `json:"hits"`
Facets []Facet `json:"facets"`
}
SearchResult is a page of hits with facet counts.
type Service ¶
type Service struct {
Store *store.Store
Policy stale.Policy
Lineage lineage.Options
// Required are label keys every image should carry.
Required []string
// Synonyms map label keys that mean the same thing, such as owner to
// team, for near-duplicate detection.
Synonyms map[string]string
// Platform is the default platform when a ref names an index.
Platform string
// RefreshEvery is how often Index refreshes the views while a crawl
// runs; zero refreshes only when it finishes.
RefreshEvery time.Duration
// Logger receives background warnings; nil discards them.
Logger *slog.Logger
Now func() time.Time
// contains filtered or unexported fields
}
Service runs queries against one index.
func (*Service) Bloat ¶
func (s *Service) Bloat(ctx context.Context, perRepo bool, minSize int64, limit int) ([]LayerStat, error)
Bloat lists large layers that only one image, or only one repo, uses.
func (*Service) Cleanup ¶ added in v0.3.0
Cleanup lists deletion candidates: images matching the filter (abandoned ones by default), grouped into whole multi-platform indexes, leaving out any that a kept image is built on, with the storage deleting them frees after accounting for layers shared with kept images.
func (*Service) Descendants ¶
func (s *Service) Descendants(ctx context.Context, ref string, opts DescendantOptions) (*DescendantResult, error)
Descendants finds everything built on a base, whatever it is named.
func (*Service) Diff ¶
func (s *Service) Diff(ctx context.Context, since time.Duration, groupBy string, darkDays int) (*Diff, error)
Diff compares the latest snapshot with the one closest to since ago, and lists repos that went dark: no pushes in darkDays while still holding tagged images.
func (*Service) Explain ¶
func (s *Service) Explain(ctx context.Context, ref, platform string, history bool) (*Explanation, error)
Explain gathers everything known about one image.
func (*Service) Index ¶
Index crawls, then recomputes lineage, staleness and today's snapshot. Progress is visible through Status while it runs, and with RefreshEvery set the views refresh during the crawl too.
func (*Service) Lifecycles ¶ added in v0.3.0
Lifecycles generates an ECR lifecycle policy per repo that expires untagged images once they are older than the staleness policy's abandoned window, the closest rule ECR can enforce to strata's abandoned verdict: ECR can see push age but not pulls or what is built on an image. Each rule is checked against the index, and a repo where it would expire an image strata keeps is skipped and says why.
func (*Service) Map ¶
Map returns root bases and up to depth levels below them, with the largest children of each node kept and leaf images grouped by repo, so the result stays drawable at any registry size. It runs as a handful of set-based queries rather than one per node.
func (*Service) NeedsRefresh ¶ added in v0.3.0
NeedsRefresh reports whether the index holds images that lineage, staleness and the views have never been computed for, as after an index run that was stopped before its refresh.
func (*Service) Outline ¶
func (s *Service) Outline(ctx context.Context, parent string, onlyStale bool, offset, limit int) (*Outline, error)
Outline returns one page of the children of an outline row: root bases when parent is empty, then bases and repo groups, then a repo group's images.
func (*Service) Overview ¶
Overview gathers the headline numbers, the roots holding the most stale images and the last week's changes.
func (*Service) QueryEach ¶
func (s *Service) QueryEach(ctx context.Context, opts QueryOptions, header func([]string) error, emit func([]any) error) error
QueryEach runs a filter and streams rows to emit, so a full-registry export never buffers. header is called once with the column names.
func (*Service) QueryGraph ¶
QueryGraph draws the images a filter matches plus their ancestry up to shared roots.
func (*Service) Refresh ¶
Refresh brings the derived views up to date with the index: lineage, staleness, subtree stats, the materialized image facts and today's snapshot. It is incremental: see refresh.
func (*Service) Resolve ¶
Resolve maps a ref to one platform manifest digest. It accepts a digest, a digest prefix of at least 12 hex characters, repo@digest, repo:tag, and repo:tag without the registry host when that is unambiguous. An index resolves to the platform given, or the service's default platform, or the first platform it holds.
func (*Service) RootsGraph ¶
RootsGraph returns every root and its whole subtree as one graph, for the registry map.
func (*Service) Search ¶
func (s *Service) Search(ctx context.Context, o SearchOptions) (*SearchResult, error)
Search runs a filter with facet selections and returns a page of hits and every facet's counts. Each facet's counts apply every selection except its own.
func (*Service) SimilarBases ¶
func (s *Service) SimilarBases(ctx context.Context) ([]BaseCluster, error)
SimilarBases finds near-duplicate bases: images with descendants whose stacks share every layer but the last one or two.
func (*Service) SimilarKeys ¶
SimilarKeys groups label keys that probably mean the same thing: equal after case folding and dropping separators, or linked by a synonym.
func (*Service) Snapshot ¶
Snapshot writes today's summary metrics, one row per group and metric, replacing any earlier snapshot from the same day. Snapshots start on the first run, like tag history, so they cannot be backfilled.
func (*Service) Status ¶ added in v0.2.0
func (s *Service) Status() IndexStatus
Status returns the state of the running or last index.
func (*Service) Summary ¶
Summary computes footprint metrics for the whole index and, with groupBy, per repo, root or label.
type StalenessInfo ¶
type StalenessInfo struct {
Verdict string `json:"verdict"`
Reasons []string `json:"reasons"`
BaseDriftGenerations int `json:"base_drift_generations"`
BaseTag string `json:"base_tag,omitempty"`
SupersededDays *int `json:"superseded_days,omitempty"`
Untagged bool `json:"untagged"`
Inferred bool `json:"inferred"`
}
StalenessInfo is an image's verdict and the signals behind it.
type Summary ¶
type Summary struct {
GroupBy string `json:"group_by,omitempty"`
Total GroupMetrics `json:"total"`
Groups []GroupMetrics `json:"groups,omitempty"`
Platforms map[string]int64 `json:"platforms"`
Compliance map[string]float64 `json:"required_label_coverage,omitempty"`
}
Summary is the shape of the registry in one screen.