Documentation
¶
Overview ¶
Package registry asks a container registry whether it will serve an image's manifest to this machine, with the credentials a scanner running here would use.
One request per image, for the manifest and never a layer, so the answer costs what the first step of a pull costs. It answers "can a scan reach this image", not "what is in it".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasCredential ¶ added in v0.162.0
HasCredential reports whether this machine holds a credential for a registry, where Trivy, Grype and Cosign read one. host may be the name a reader types or the API host.
func LoginHost ¶ added in v0.162.0
LoginHost is a registry as a reader names it to `docker login`. Docker Hub's API host is not what anybody types.
func RefusalStatus ¶ added in v0.162.0
RefusalStatus reads a scanner's account of a failed pull of an image on host for the registry declining to serve it. It returns the HTTP status the refusal amounts to, 401 when the registry asked for a credential and 403 when it declined the request it was given, or 0 when the message is not a refusal.
Read a line at a time. A line naming a request to another host is about something else, such as the vulnerability database a scanner downloads before it pulls the image, and is passed over. A line naming no request is taken at its word, because a message shortened to fit a terminal loses its start first.
func ShortDigest ¶ added in v0.162.0
ShortDigest is an image reference as a terminal row names it, its digest cut to twelve hex characters and marked as cut. A reference with no digest, or a short one, is returned as it is.
Types ¶
type Client ¶
type Client struct {
// HTTP makes the requests. nil means a client honoring the proxy environment.
HTTP *http.Client
// Credential returns the credential for a registry host, or a zero Credential when there is
// none. nil means the Docker configuration, as Trivy, Grype and Cosign read it.
Credential func(ctx context.Context, host string) (Credential, error)
}
Client checks images against their registries.
type Credential ¶
type Credential struct {
Username, Password string
// IdentityToken is a refresh token, exchanged for an access token at the registry's realm.
IdentityToken string
}
Credential is what a registry is authenticated with. The zero value is anonymous.
func DockerCredential ¶
func DockerCredential(ctx context.Context, host string) (Credential, error)
DockerCredential returns the credential this machine holds for a registry host: from a credential helper named for the host, the configured credential store, or an entry in the file itself, in that order. A zero Credential with no error means none is configured.
type Reference ¶
type Reference struct {
Host string
Repository string
// Reference is the digest when the image names one, the tag otherwise.
Reference string
}
Reference is an image reference split the way a registry is addressed.
type StatusError ¶
type StatusError struct {
Code int
// Host is the registry, named when no credential was found for it so the reader knows which
// login is missing.
Host string
Anonymous bool
}
StatusError is a registry refusing the manifest.
func (*StatusError) Error ¶
func (e *StatusError) Error() string