registry

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package registry provides OCI registry client functionality.

Index

Constants

View Source
const (
	DefaultRegistry = "registry-1.docker.io"
	DefaultTag      = "latest"
	AuthService     = "registry.docker.io"
	AuthRealm       = "https://auth.docker.io/token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Username      string `json:"username,omitempty"`
	Password      string `json:"password,omitempty"`
	ServerAddress string `json:"serveraddress,omitempty"`
	IdentityToken string `json:"identitytoken,omitempty"`
}

AuthConfig holds registry authentication credentials.

type Client

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

Client provides access to an OCI/Docker registry.

func NewClient

func NewClient(insecure bool) *Client

NewClient creates a new OCI registry client with the given TLS settings.

func (*Client) Close

func (c *Client) Close()

Close releases idle HTTP connections held by the client.

func (*Client) DoRequest

func (c *Client) DoRequest(ctx context.Context, method, urlStr string, headers map[string]string, body io.Reader) (*http.Response, error)

DoRequest performs an authenticated HTTP request to a registry endpoint.

func (*Client) DownloadBlob

func (c *Client) DownloadBlob(registry, name, digest string, writer io.Writer) error

DownloadBlob downloads a blob by digest and writes it to the provided writer.

func (*Client) GetBlob

func (c *Client) GetBlob(registry, name, digest string) ([]byte, error)

GetBlob downloads a blob by digest and returns its raw bytes.

func (*Client) GetConfig

func (c *Client) GetConfig(registry, name string, manifest *ManifestV2) ([]byte, error)

GetConfig downloads the image configuration blob referenced by a manifest.

func (*Client) GetManifest

func (c *Client) GetManifest(registry, name, reference string) (*ManifestV2, string, error)

GetManifest fetches the image manifest for a given reference.

func (*Client) GetTags

func (c *Client) GetTags(registry, repository string) (*TagList, error)

GetTags lists all tags for a repository.

func (*Client) HeadBlob

func (c *Client) HeadBlob(registry, name, digest string) (int64, error)

HeadBlob returns the content length of a blob by digest.

func (*Client) Ping

func (c *Client) Ping(registry string) error

Ping checks connectivity to a registry's v2 API endpoint.

func (*Client) Push

func (c *Client) Push(registry, name, tag string, manifest *ManifestV2, config []byte, layers map[string]io.Reader) error

Push uploads a manifest and its blobs to a registry.

func (*Client) ResolveManifest

func (c *Client) ResolveManifest(registry, name, reference string) (*ManifestV2, string, error)

ResolveManifest resolves a manifest for the current platform (linux/arm64 preferred).

func (*Client) SetAuth

func (c *Client) SetAuth(username, password string)

SetAuth sets basic authentication credentials for the client.

type ImageRef

type ImageRef struct {
	Registry string
	Name     string
	Tag      string
	Digest   string
}

ImageRef represents a parsed OCI image reference.

func ParseImageRef

func ParseImageRef(ref string) (*ImageRef, error)

ParseImageRef parses an OCI image reference string into its components.

func (*ImageRef) FullName

func (ir *ImageRef) FullName() string

FullName returns the registry/name combination without tag or digest.

func (*ImageRef) String

func (ir *ImageRef) String() string

String returns the full image reference string.

type ManifestBlob

type ManifestBlob struct {
	MediaType   string            `json:"mediaType"`
	Size        int64             `json:"size"`
	Digest      string            `json:"digest"`
	URLs        []string          `json:"urls,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

ManifestBlob represents a blob entry within an image manifest.

type ManifestList

type ManifestList struct {
	SchemaVersion int                 `json:"schemaVersion"`
	MediaType     string              `json:"mediaType"`
	Manifests     []ManifestListEntry `json:"manifests"`
}

ManifestList represents an OCI image index or Docker manifest list.

type ManifestListEntry

type ManifestListEntry struct {
	MediaType   string            `json:"mediaType"`
	Size        int64             `json:"size"`
	Digest      string            `json:"digest"`
	Platform    *Platform         `json:"platform"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

ManifestListEntry represents a single entry in a manifest list.

type ManifestV2

type ManifestV2 struct {
	SchemaVersion int               `json:"schemaVersion"`
	MediaType     string            `json:"mediaType"`
	Config        ManifestBlob      `json:"config"`
	Layers        []ManifestBlob    `json:"layers"`
	Annotations   map[string]string `json:"annotations,omitempty"`
}

ManifestV2 represents an OCI/Docker v2 image manifest.

type Platform

type Platform struct {
	Architecture string `json:"architecture"`
	OS           string `json:"os"`
	Variant      string `json:"variant,omitempty"`
}

Platform describes the target OS and architecture for a manifest.

type TagList

type TagList struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

TagList represents a list of tags for a repository.

Jump to

Keyboard shortcuts

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