dockerhub

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dockerhub is a minimal client for Docker Hub's public, unauthenticated API: repository search and tag listing.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("dockerhub: repository not found")

ErrNotFound reports that Docker Hub has no such repository, the Hub API's own signal (a 404) for a namespace/name nothing was ever published under, distinct from an unreachable host or a rate limit.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP *http.Client
	// BaseURL overrides defaultBaseURL, for tests only.
	BaseURL string
}

Client queries Docker Hub's public Hub API over plain HTTPS: no authentication, so no credentials to manage or leak.

func NewClient

func NewClient() *Client

NewClient returns a Client with a bounded per-request timeout, the same shape registrycatalog.NewClient establishes for its own single small JSON requests.

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, namespace, repository string, pageSize int) ([]Tag, error)

ListTags queries GET /v2/repositories/{namespace}/{repo}/tags. An empty namespace defaults to "library", the namespace Docker Hub's own search results omit for official images.

func (*Client) SearchRepositories

func (c *Client) SearchRepositories(ctx context.Context, query string, pageSize int) ([]Repository, error)

SearchRepositories queries GET /v2/search/repositories/?query=..., returning Docker Hub's own relevance-ranked order unchanged.

type Repository

type Repository struct {
	Name             string `json:"repo_name"`
	ShortDescription string `json:"short_description"`
	StarCount        int    `json:"star_count"`
	IsOfficial       bool   `json:"is_official"`
	IsAutomated      bool   `json:"is_automated"`
}

Repository is one GET /v2/search/repositories/ result: the fields the picker's search results list needs (name, description, popularity, official/automated flags), not the full upstream payload.

type Tag

type Tag struct {
	Name string `json:"name"`
}

Tag is one GET /v2/repositories/{namespace}/{repo}/tags result: just the tag name, the same "name only" shape registrycatalog.ListTags returns for the built-in registry.

Jump to

Keyboard shortcuts

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