ociartifact

package
v0.2.8 Latest Latest
Warning

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

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

Documentation

Overview

Package ociartifact acquires first-class Argo CD OCI artifact sources (repoURL "oci://…" without chart:) by wrapping the vendored Argo CD OCI client. Revision resolution and extraction guards follow argo-cd v3.4.5 util/oci/client.go; the image cache is a drydock-owned layout under the OCI cache root so `drydock cache` can list and prune it.

Index

Constants

View Source
const EntryKind = "image"

EntryKind is the cache metadata kind recorded for OCI artifact image entries (source "oci", kind "image").

Variables

This section is empty.

Functions

func DefaultCacheDir

func DefaultCacheDir() (string, error)

func EntryKey

func EntryKey(repoURL, version string) string

EntryKey derives the 64-hex cache entry key from (url, version).

func EntryPath

func EntryPath(cacheDir, repoURL, version string) string

EntryPath returns the cache entry directory for (url, version).

func ImageTarPath

func ImageTarPath(entryPath string) string

ImageTarPath returns the cached image tar location inside an entry.

func IsDigest

func IsDigest(revision string) bool

IsDigest reports whether revision is a digest-pinned reference.

func IsOCIURL

func IsOCIURL(repoURL string) bool

IsOCIURL reports whether repoURL names an OCI registry source. It is total over oci:// spellings: surrounding whitespace and scheme casing do not change classification, so no spelling can fall through to the local path-exists or git-acquisition branches. Argo CD matches the exact lowercase prefix (v1alpha1 types.go:317-319); accepting case variants only widens classification, never re-routes a URL argo would treat as OCI.

func NormalizeURL

func NormalizeURL(repoURL string) string

NormalizeURL canonicalizes an OCI repository URL for cache keys and records: whitespace and trailing slashes trimmed, scheme dropped (the argo client keys its cache on the schemeless repo path, util/oci/client.go:125).

func RedactURL

func RedactURL(repoURL string) string

RedactURL returns the URL form safe for errors and cache events: URL userinfo is dropped (mirroring remote.RedactURL), so credentials embedded in a repoURL spelling never reach error text or cache metadata.

func ResolveCacheDir

func ResolveCacheDir(cacheDir string, forbiddenRoots []string) (string, error)

ResolveCacheDir follows the chart cache-dir validation pattern (chart.ResolveCacheDir): default under the user cache dir, absolute, and never inside a protected root.

Types

type Acquirer

type Acquirer interface {
	Resolve(ctx context.Context, repoURL, revision string, opts Options) (string, error)
	Extract(ctx context.Context, repoURL, digest string, opts Options) (string, func(), error)
}

Acquirer is the OCI artifact acquisition seam. Resolve turns a tag, semver constraint, or digest into a concrete digest; Extract materializes the artifact content for that digest into a directory and returns a release callback for it.

type Credentials

type Credentials struct {
	Username           string
	Password           string
	CAFile             string
	ClientCertFile     string
	ClientKeyFile      string
	InsecureSkipVerify bool
}

Credentials carries OCI registry auth and TLS material in flag-shaped form (file PATHS, not contents), mirroring chart.ChartCredentials. The single global set is presented to every OCI registry a run touches (helm/git parity); per-registry maps stay a recorded follow-up.

func (Credentials) Validate

func (c Credentials) Validate() error

Validate fails fast at request construction with errors naming the flag. The vendored client silently degrades on both mistakes guarded here: the AppendCertsFromPEM return for CAPath is ignored (vendored client.go:482 — a non-PEM CA file would silently yield an EMPTY RootCAs pool that also REPLACES the system pool), and CertData/KeyData are ignored unless BOTH are set (client.go:486 — a lone cert or key would be silently dropped).

type DefaultAcquirer

type DefaultAcquirer struct{}

DefaultAcquirer wraps util/oci.NewClientWithLock. Every exported method of the argo client calls its embedded EventHandlers unconditionally and NewClientWithLock installs no defaults (util/oci/client.go:232,244,357, 373,410), so no-op handlers are mandatory. Resolve injects a drydock-owned prefetch-populated tags memo via WithIndexCache (see prefetchedTagsCache) — the upstream SetOCITags write path stores an empty read buffer (util/oci/client.go:450-452) and is deliberately ignored.

func (DefaultAcquirer) Extract

func (a DefaultAcquirer) Extract(ctx context.Context, repoURL, digest string, opts Options) (string, func(), error)

Extract materializes the artifact content for digest. With a committed image tar cached, the argo client extracts locally without network; offline without a cached tar it fails with the offline cache miss contract error instead of letting the client reach the registry. Online, a cached tar that fails to extract (truncated by an interrupted earlier run or corrupted externally) is deleted and re-fetched once, so a bad tar never poisons every future run.

func (DefaultAcquirer) Resolve

func (a DefaultAcquirer) Resolve(ctx context.Context, repoURL, revision string, opts Options) (string, error)

Resolve resolves revision to a digest. Digest-pinned revisions pass through without network. Online, resolution mirrors argo-cd v3.4.5 util/oci/client.go:384-407 exactly: the literal revision resolves first via a registry HEAD, and only when that fails does a constraint-shaped revision fall back to MaxVersion over the tag list. Offline, resolution is seam-level from records captured on earlier online runs, in the same exact-first order; the argo client is never constructed.

type Options

type Options struct {
	CacheDir       string
	Offline        bool
	ForbiddenRoots []string
	Credentials    Credentials
	// OnAcquired is invoked by the production acquirer exactly once per real
	// (non-memoized) successful Extract, with fromImageCache reporting whether
	// the image tar was already cached before the call. Session memo hits never
	// invoke it, which is what makes single-acquisition event assertions
	// memo-sensitive. Fakes should call it when simulating an extraction.
	OnAcquired func(fromImageCache bool)
}

Options carries per-call acquisition inputs, mirroring chart.Options.

Directories

Path Synopsis
Package ocitest provides hermetic OCI registry fixtures for drydock tests: an httptest-mounted distribution server plus artifact push helpers shaped like the artifacts the Argo CD OCI client consumes (helm chart artifacts, plain-manifest artifacts, and guard-violating variants).
Package ocitest provides hermetic OCI registry fixtures for drydock tests: an httptest-mounted distribution server plus artifact push helpers shaped like the artifacts the Argo CD OCI client consumes (helm chart artifacts, plain-manifest artifacts, and guard-violating variants).

Jump to

Keyboard shortcuts

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