registrypush

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package registrypush pushes images from hypeman's OCI cache to remote container registries.

Credentials are resolved by Provider implementations keyed on the target reference. The push itself is registry-agnostic; registries with custom auth flows plug in as additional providers without touching the push path.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("registry authentication failed")

ErrUnauthorized means the destination registry rejected the push credentials. On pull a 401 is treated as "image not visible"; on push it is a caller-fixable credential problem and must surface as such.

Functions

This section is empty.

Types

type KeychainProvider

type KeychainProvider struct {
	Keychain authn.Keychain
}

KeychainProvider resolves credentials from a Docker-style keychain. A nil Keychain uses authn.DefaultKeychain, which reads ~/.docker/config.json including any configured credential helpers.

func (*KeychainProvider) Authenticator

func (p *KeychainProvider) Authenticator(ctx context.Context, ref name.Reference) (authn.Authenticator, error)

Authenticator resolves credentials for the target registry from the keychain. The caller's context is forwarded so context-aware keychains (authn.ContextKeychain) receive cancellation and deadlines.

type Multi

type Multi struct {
	Default Provider
	ByHost  map[string]Provider
}

Multi routes credential resolution by registry host. The provider whose key matches the target's registry host wins; everything else falls back to Default. Keys must match the canonical host form reported by name.Registry.RegistryStr (e.g. "index.docker.io" for Docker Hub). A nil Default resolves anonymously.

func (*Multi) Authenticator

func (m *Multi) Authenticator(ctx context.Context, ref name.Reference) (authn.Authenticator, error)

Authenticator dispatches to the provider registered for the target host.

type Options

type Options struct {
	// Insecure allows pushing to plain-HTTP registries. Localhost registries
	// are always treated as http by go-containerregistry regardless of this
	// flag.
	Insecure bool
}

Options configures a push.

type Provider

type Provider interface {
	Authenticator(ctx context.Context, ref name.Reference) (authn.Authenticator, error)
}

Provider resolves credentials for pushing to a target reference.

type Result

type Result struct {
	// Reference is the target reference the image was pushed to.
	Reference string
	// Digest is the pushed manifest digest.
	Digest string
	// Layers is the number of layers in the pushed image.
	Layers int
	// Bytes is the total compressed size of the pushed layers.
	Bytes int64
}

Result describes a completed push.

func Push

func Push(ctx context.Context, img v1.Image, target string, provider Provider, opts Options) (*Result, error)

Push writes img to the target reference using credentials from provider. A nil provider pushes anonymously. Pushed blobs are identical to the source image. For OCI images the manifest digest is preserved end to end; for Docker v2 inputs the manifest is converted to OCI on push, so the pushed digest is the converted digest (see Result.Digest). Registry errors are classified with classifyPushError so callers can distinguish authentication failures, rate limits, and missing repositories from transport failures.

func PushFromCache

func PushFromCache(ctx context.Context, p *paths.Paths, digest, target string, provider Provider, opts Options) (*Result, error)

PushFromCache pushes the image stored in the local OCI cache under the given manifest digest. Returns ocicache.ErrNotFound if the digest is not in the cache (source phase) or images.ErrNotFound if the destination registry reports the repository or manifest as missing (target phase).

type StaticProvider

type StaticProvider struct {
	Config authn.AuthConfig
}

StaticProvider always returns the same fixed credentials, regardless of target. Useful for a single pre-configured destination.

func (*StaticProvider) Authenticator

Authenticator returns the configured credentials.

Jump to

Keyboard shortcuts

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