Documentation
¶
Overview ¶
Package imgregistry is a minimal Docker Registry v2 HTTP client used to browse the fleet's image registry and resolve tags/digests for the upgrade-picker. Deliberately not named "registry" — the codebase already has jobs.Registry (job-kind registry) and a same-named package here would collide in every import block needing both.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound wraps a registry's genuine 404 response (NAME_UNKNOWN / MANIFEST_UNKNOWN) — the registry answered and said this repo/tag doesn't exist.
var ErrUnreachable = errors.New("registry unreachable")
ErrUnreachable wraps a transport failure, a non-404 non-2xx response, or a response body this client cannot decode — anything that means "we could not get a straight answer from the registry," as distinct from ErrNotFound ("the registry answered and said no"). Callers must not collapse the two: an operator told "not found" for a registry that is simply down gets the exact misleading signal this package exists to prevent.
Functions ¶
func ValidRef ¶
ValidRef reports whether ref is an acceptable manifest reference: either a tag (tagRe) or a content digest (digestRe). Callers must validate ref before passing it to Client.Manifest, which interpolates it unescaped into a registry request path — an unvalidated ref (e.g. containing "../" or "/") would let a caller steer that request to an arbitrary path on the registry host.
func ValidRepoName ¶
ValidRepoName reports whether repo is an acceptable Docker Registry v2 repository name: one or more "/"-separated components, each matching repoComponentRe. Registry v2 repo names legally contain "/" (e.g. "iotready/engine"), unlike the DNS-label-style names (host/template/slug) validated elsewhere by render.ValidName — so this validator is intentionally separate, not a reuse of that one. Shared by internal/api and internal/ui so the two edges cannot drift into accepting different repo shapes.
Types ¶
type Client ¶
type Client interface {
Catalog(ctx context.Context) ([]string, error)
Tags(ctx context.Context, repo string) ([]TagGroup, error)
Manifest(ctx context.Context, repo, ref string) (Manifest, error)
}
Client is the read-only surface this package exposes.
type HTTPClient ¶
type HTTPClient struct {
BaseURL string // e.g. "http://100.64.0.23:5000", no trailing slash
Auth Auth
HTTP *http.Client
}
HTTPClient implements Client against a real Registry v2 server.
func NewHTTPClient ¶
func NewHTTPClient(baseURL string, auth Auth) *HTTPClient
NewHTTPClient builds an HTTPClient with a sane default timeout.
func (*HTTPClient) Catalog ¶
func (c *HTTPClient) Catalog(ctx context.Context) ([]string, error)
Catalog lists every repository in the registry, following the Link response header across pages rather than requesting one unbounded page.
func (*HTTPClient) Manifest ¶
Manifest fetches a single manifest by tag or digest and returns its canonical digest (from Docker-Content-Digest) plus size/layer info.
func (*HTTPClient) Tags ¶
Tags lists every tag in repo, resolves each to its manifest digest, and groups tags that share a digest into one TagGroup. Each unique digest's config blob is fetched once (not once per tag) for its Created timestamp. Manifest and blob-created lookups both run with bounded concurrency (tagResolveConcurrency), not sequentially. Groups are sorted newest-Created-first.