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 ¶
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.