registry

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ChallengeHeader = "WWW-Authenticate"
View Source
const ContentDigestHeader = "Docker-Content-Digest"
View Source
const DefaultRegistry = "registry-1.docker.io"
View Source
const DefaultRegistryDomain = "docker.io"
View Source
const DefaultRegistryHost = "index.docker.io"

Variables

This section is empty.

Functions

func AcquireTokenViaChallenge

func AcquireTokenViaChallenge(
	ctx context.Context,
	registryHost string,
	repository string,
	challengeHeader string,
	enabledRegs []models.ContainerRegistry,
) (string, string, string, error)

AcquireTokenViaChallenge: Parses a WWW-Authenticate Bearer challenge, builds an auth URL, tries anonymous multi-scope token, then credential-based. Returns (token, method, username, error)

func GetAuthHeaderForImage

func GetAuthHeaderForImage(ctx context.Context, imageRef string, enabledRegs []models.ContainerRegistry) (string, error)

GetAuthHeaderForImage performs the /v2/ challenge for an image and returns a usable Authorization header. It supports Basic and Bearer challenges. For Bearer, it reuses AcquireTokenViaChallenge which looks up credentials from the database (enabledRegs) when needed.

func GetChallengeRequest

func GetChallengeRequest(ctx context.Context, u url.URL) (*http.Request, error)

func GetChallengeURL

func GetChallengeURL(imageRef string) (url.URL, error)

GetChallengeURL returns https://<host>/v2/ for a given image ref (normalized). host is normalized so docker.io => index.docker.io.

func GetRegistryAddress

func GetRegistryAddress(imageRef string) (string, error)

func ResolveAuthHeaderForRepository

func ResolveAuthHeaderForRepository(ctx context.Context, host, repository, tag string, enabledRegs []models.ContainerRegistry) (string, string, string, error)

Types

type Client

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

Client provides helper methods for Docker/OCI registries.

func NewClient

func NewClient() *Client

func (*Client) CheckAuth

func (c *Client) CheckAuth(ctx context.Context, registry string) (string, error)

func (*Client) GetLatestDigest

func (c *Client) GetLatestDigest(ctx context.Context, registry, repository, tag, token string) (string, error)

func (*Client) GetLatestDigestTimed

func (c *Client) GetLatestDigestTimed(ctx context.Context, registry, repository, tag, token string) (string, time.Duration, error)

func (*Client) GetRegistryURL

func (c *Client) GetRegistryURL(registry string) string

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context, authURL, repository string, creds *Credentials) (string, error)

func (*Client) GetTokenMulti

func (c *Client) GetTokenMulti(ctx context.Context, authURL string, repositories []string, creds *Credentials) (string, error)

func (*Client) ParseAuthChallenge

func (c *Client) ParseAuthChallenge(header string) (string, string)

type Credentials

type Credentials struct {
	Username string
	Token    string
}

type TestResult

type TestResult struct {
	OverallSuccess bool      `json:"overall_success"`
	PingSuccess    bool      `json:"ping_success"`
	AuthSuccess    bool      `json:"auth_success"`
	CatalogSuccess bool      `json:"catalog_success"`
	URL            string    `json:"url"`
	Domain         string    `json:"domain"`
	Timestamp      time.Time `json:"timestamp"`
	Errors         []string  `json:"errors"`
}

func TestRegistryConnection

func TestRegistryConnection(ctx context.Context, registryURL string, creds *Credentials) (*TestResult, error)

Jump to

Keyboard shortcuts

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