oci

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 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 oci lists the tags of container images and reads their source labels from OCI and Docker registries, with anonymous pull tokens.

Index

Constants

View Source
const (
	DockerHub     = "docker.io"
	DockerHubAPI  = "registry-1.docker.io"
	DockerHubAuth = "auth.docker.io"
)

Docker Hub's names: the one in image references, the host of its registry API and the host that issues its anonymous tokens.

View Source
const (
	LabelSource = "org.opencontainers.image.source"
	LabelVCSURL = "org.label-schema.vcs-url"
)

Source label keys, newest first.

Variables

View Source
var (
	ErrNotAllowed = errors.New("registry not allowed")
	ErrBadRef     = errors.New("not an image reference")
)

Errors wrapped by Client methods.

Functions

func DefaultRegistries

func DefaultRegistries() []string

DefaultRegistries returns the registries relgap reads tags from without configuration.

Types

type Client

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

Client lists tags and reads source labels from image registries with anonymous tokens.

func New

func New(hc *http.Client, o Options) *Client

New returns a client that sends requests through hc.

func (*Client) Check

func (c *Client) Check(r Ref) error

Check returns an error wrapping ErrNotAllowed unless the client may contact r's registry.

func (*Client) Source

func (c *Client) Source(ctx context.Context, r Ref, tag string) (string, error)

Source returns the source repository URL that the image r:tag names in its annotations or labels, or "" when it names none. It reads the manifest, then the linux/amd64 manifest of an index, then the image config, and stops at the first that has a source.

func (*Client) Tags

func (c *Client) Tags(ctx context.Context, r Ref) ([]string, error)

Tags lists every tag of r, following Link rel="next" on the registry's own host.

func (*Client) URL

func (c *Client) URL(r Ref) string

URL returns the tags list URL of r, which says where its versions come from.

type Options

type Options struct {
	Registries []string // registries the client may contact; nil means [DefaultRegistries]
	Scheme     string   // https unless a test sets http
}

Options configures New.

type Ref

type Ref struct {
	Registry   string // as written, with docker.io for Docker Hub
	Repository string // with library/ for a one-part Docker Hub name
}

Ref is an image name split into its registry and repository.

func ParseRef

func ParseRef(name string) (Ref, error)

ParseRef splits an image name without tag or digest, as Docker does: the first part is a registry when it has a dot or a colon or is localhost, and Docker Hub otherwise.

func (Ref) String

func (r Ref) String() string

String returns registry/repository.

Jump to

Keyboard shortcuts

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