registry

package
v0.32.2 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: 12 Imported by: 0

Documentation

Overview

Package registry is the thin domain layer of `d8 cr` on top of go-containerregistry/pkg/v1/*. It replaces the upstream pkg/crane facade - we own every entry point, error message and option default.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(ctx context.Context, ref string, opts *Options) (v1.Image, error)

Fetch resolves ref and returns a v1.Image. For multi-arch indices remote.Image picks the current runtime platform unless opts.Platform pins another one.

func FetchConfig

func FetchConfig(ctx context.Context, ref string, opts *Options) ([]byte, error)

FetchConfig returns the config JSON for ref. Multi-arch indices are resolved via the caller's platform (set on Options).

func FetchDescriptor

func FetchDescriptor(ctx context.Context, ref string, opts *Options) (*remote.Descriptor, error)

FetchDescriptor returns the raw remote descriptor, leaving media-type dispatch to the caller (pull uses it to tell an index from an image).

func FetchDigest

func FetchDigest(ctx context.Context, ref string, opts *Options) (string, error)

FetchDigest returns "sha256:<hex>" for ref's manifest as served.

func FetchManifest

func FetchManifest(ctx context.Context, ref string, opts *Options) ([]byte, error)

FetchManifest returns the raw manifest bytes as the registry served them. This preserves signatures and byte-for-byte JSON the user may want to pipe.

func InsecureTransport

func InsecureTransport() http.RoundTripper

InsecureTransport returns a fresh http.Transport cloned from remote's default with TLS verification disabled. Use only when the user explicitly opts in via --insecure.

func ListCatalog

func ListCatalog(ctx context.Context, regRef string, opts *Options, visit func(repos []string) error) error

ListCatalog invokes visit for every repository page on the given registry. Not every registry implements /v2/_catalog - the underlying call will surface a 404 through the error chain.

func ListTags

func ListTags(ctx context.Context, repoRef string, opts *Options, visit func(tags []string) error) error

ListTags invokes visit for every tag page of repo. Stopping early: return a non-nil error (context.Canceled is reasonable for user abort).

func NewStaticKeychain added in v0.30.18

func NewStaticKeychain(username, password string) authn.Keychain

NewStaticKeychain returns a keychain that always resolves to the given username/password, regardless of the target registry.

func Push

func Push(ctx context.Context, ref string, obj partial.WithRawManifest, opts *Options) (v1.Hash, error)

Push writes obj (v1.Image or v1.ImageIndex) under ref and returns the resulting digest. Anything else is a programmer error.

Types

type LoginResult added in v0.30.18

type LoginResult struct {
	// ServerAddress is the key the credentials were stored under. For Docker
	// Hub this is the canonical "https://index.docker.io/v1/".
	ServerAddress string
	// ConfigFile is the path to the Docker config the credentials were
	// written to (or the backing file of the active credential store).
	ConfigFile string
}

LoginResult reports where the credentials ended up so the caller can tell the user which file/store now holds them.

func Login added in v0.30.18

func Login(ctx context.Context, host, username, password string, opts *Options) (*LoginResult, error)

Login verifies username/password against host and, on success, persists them into the Docker config (the same store authn.DefaultKeychain reads), so every other cr command can authenticate transparently afterwards.

An empty host targets Docker Hub. Verification builds the registry's auth transport and then performs an authenticated GET /v2/: a rejected login answers 401 there, so invalid credentials fail rather than silently writing a broken config. (The transport handshake alone only validates bearer-token registries; the explicit /v2/ probe is what also covers basic-auth ones.)

type Options

type Options struct {
	Remote   []remote.Option
	Name     []name.Option
	Platform *v1.Platform
	Keychain authn.Keychain
	Context  context.Context

	// Transport mirrors the http.RoundTripper installed via WithTransport.
	// remote.* receives it through o.Remote; we also keep a direct handle so
	// auth-only flows (e.g. Login) that talk to the registry transport
	// package can honour --insecure without re-deriving it from o.Remote.
	Transport http.RoundTripper
}

Options accumulates everything the domain layer needs to talk to a registry: auth, transport, platform hint, name-parsing flags. Each builder mutates the receiver and returns it so calls chain.

The two slices (Remote, Name) are what actually gets passed to go-containerregistry: Remote to remote.*, Name to name.ParseReference / name.NewRepository / name.NewRegistry / name.NewTag.

func New

func New() *Options

New returns Options seeded with the default Docker keychain and a background context. Keychain / platform / context are NOT baked into o.Remote here - they are finalized lazily by remoteWithContext at fetch time so repeated builder calls (e.g. WithPlatform twice with different values) cannot stack duplicate options on the slice.

func (*Options) WithContext

func (o *Options) WithContext(ctx context.Context) *Options

WithContext replaces the ambient context.

func (*Options) WithInsecure

func (o *Options) WithInsecure() *Options

WithInsecure tolerates non-TLS references during name parsing. The HTTP transport itself is configured separately via WithTransport.

func (*Options) WithKeychain

func (o *Options) WithKeychain(kc authn.Keychain) *Options

WithKeychain replaces the keychain that authenticates registry calls. Last call wins.

func (*Options) WithNondistributable

func (o *Options) WithNondistributable() *Options

WithNondistributable allows pushing foreign (non-distributable) layers.

func (*Options) WithPlatform

func (o *Options) WithPlatform(p *v1.Platform) *Options

WithPlatform pins a target platform for multi-arch indices. Nil is a no-op (so a flag-driven caller can pass the parsed result directly without branching). Last non-nil call wins.

func (*Options) WithTransport

func (o *Options) WithTransport(t http.RoundTripper) *Options

WithTransport installs a custom HTTP transport (typically a clone of remote.DefaultTransport with TLS skip-verify toggled).

Jump to

Keyboard shortcuts

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