Documentation
¶
Overview ¶
internal/fleet/upstream/client.go
internal/fleet/upstream/enrich.go
internal/fleet/upstream/registry.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enrich ¶
func Enrich(ctx context.Context, client *Client, diffs []fleet.ImageDiff, maxEnrich int) []fleet.ImageDiff
Enrich populates Changelog on each TagDrift diff in-place, using parallel goroutines. Skips non-TagDrift rows, rows where image doesn't map to a known upstream, and rows when ctx expires. All failures are soft (logged via slog.Debug, not propagated).
maxEnrich caps the total number of diffs enriched (to bound API usage). Pass 30 for the default. Passing 0 is a no-op (returns diffs unchanged).
Deduplication: if multiple TagDrift rows share the same (upstream slug, base tag, head tag), the Compare API is called only once and the result is shared across all matching rows.
func Resolve ¶
Resolve maps a docker image name (registry+repo, no tag) to a GitHub "owner/repo" identifier suitable for the Compare API. Returns ok=false when no mapping is known and no ghcr.io-style auto-detect applies.
Order of resolution:
- Exact match in the hardcoded registry.
- Prefix "ghcr.io/" → strip and return first two path segments as owner/repo. Requires exactly 2+ path segments after the prefix; returns ok=false otherwise.
- Anything else: ok=false.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client makes GitHub Compare API calls to produce Changelog values.
func (*Client) Compare ¶
Compare returns the GitHub /compare/{base}...{head} payload, normalised into our Changelog shape. Attempts tag forms in order: <tag>, v<tag>, release-<tag> for both base and head simultaneously.
Returns Resolved=false (never a non-nil error) for soft failures:
- HTTP 404 (one of the tags doesn't exist; all forms tried)
- HTTP 422 (refs don't share an ancestor)
- HTTP 403 with X-RateLimit-Remaining: 0 (rate limit)
- Context timeout or cancellation
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the GitHub API base URL. Used in tests to point at an httptest.Server. Production code should never call this.
func WithHTTPClient ¶
WithHTTPClient overrides the underlying http.Client.
func WithTimeout ¶
WithTimeout sets per-request timeout. Default 8s.