upstream

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

func Resolve(image string) (githubSlug string, ok bool)

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:

  1. Exact match in the hardcoded registry.
  2. 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.
  3. 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 New

func New(opts ...Option) *Client

New creates a new Client with the given options applied.

func (*Client) Compare

func (c *Client) Compare(ctx context.Context, slug, base, head string) (*fleet.Changelog, error)

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

func WithBaseURL(u string) Option

WithBaseURL overrides the GitHub API base URL. Used in tests to point at an httptest.Server. Production code should never call this.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient overrides the underlying http.Client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets per-request timeout. Default 8s.

func WithToken

func WithToken(t string) Option

WithToken sets the GitHub PAT or App-installation token.

Jump to

Keyboard shortcuts

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