Help us shape the future of Go! Take the 2026 Go Developer Survey

registryauth

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package registryauth supplies container-registry credentials and mirror rewriting for every image pull Gopherstack performs.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSetting = errors.New("invalid docker registry setting")

ErrInvalidSetting is returned for malformed registry settings; it never echoes the offending value because it may carry a password.

Functions

func Configure

func Configure(s Settings) error

Configure installs the process-wide resolver built from s.

func EncodeCredential

func EncodeCredential(host, user, pass string) string

EncodeCredential returns the registryAuth header value for one explicit credential.

func HostOf

func HostOf(ref string) string

HostOf returns the registry host an image reference pulls from.

func Pull

func Pull(ctx context.Context, ref string, pull PullFunc, tag TagFunc) error

Pull pulls ref through the default resolver.

Types

type ImageTagger

type ImageTagger interface {
	ImageTag(ctx context.Context, source, target string) error
}

ImageTagger is implemented by Docker clients able to alias an image.

type PullFunc

type PullFunc func(ctx context.Context, ref, registryAuth string) error

PullFunc pulls ref using the base64url-JSON registryAuth (may be empty).

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver chooses credentials and mirrors for image pulls.

func Default

func Default() *Resolver

Default returns the process-wide resolver, creating a credentials-from-docker-config only resolver when Configure was never called.

func New

func New(s Settings) (*Resolver, error)

New builds a Resolver from settings.

func (*Resolver) AuthFor

func (r *Resolver) AuthFor(ctx context.Context, host string) string

AuthFor returns the registryAuth header value for host, or "" when none is known.

func (*Resolver) Pull

func (r *Resolver) Pull(ctx context.Context, ref string, pull PullFunc, tag TagFunc) error

Pull pulls ref with per-host credentials, trying a configured mirror first (retagging to ref on success) and falling back to the original registry.

func (*Resolver) RegisterEmulated

func (r *Resolver) RegisterEmulated(host, user, pass string)

RegisterEmulated marks host as an in-process registry (e.g. the ECR emulator) that accepts the given credentials without further configuration.

type Settings

type Settings struct {
	Auth []string `` //nolint:lll // config struct tags are intentionally verbose
	/* 138-byte string literal not displayed */
	Mirror []string `` //nolint:lll // config struct tags are intentionally verbose
	/* 191-byte string literal not displayed */
}

Settings is embedded in the root CLI.

type TagFunc

type TagFunc func(ctx context.Context, source, target string) error

TagFunc aliases an already-pulled source image as target.

func TaggerFrom

func TaggerFrom(client any) TagFunc

TaggerFrom returns a TagFunc backed by client, or nil when it cannot tag.

Jump to

Keyboard shortcuts

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