Documentation
¶
Index ¶
- Variables
- func IsRelative(ref string) bool
- func JoinRef(repository, reference string) string
- func OpenArchive(ctx context.Context, c Client, ref string, platform Platform) (io.ReadCloser, int64, error)
- func OpenSource(ctx context.Context, c Client, ref string) (io.ReadCloser, int64, error)
- func PullArtifactBytes(ctx context.Context, c Client, ref, wantMediaType string) ([]byte, error)
- func ResolveRef(rawRef, kind, name, base string) (string, error)
- func SplitRef(ref string) (name, reference string)
- func WithDefaultTag(ref string) string
- type Client
- type CredentialFunc
- type MissingCatalogBaseError
- type NotAManifestError
- type NotAnImageIndexError
- type Option
- type Platform
- type UnexpectedMediaTypeError
- type UnsupportedPlatformError
Constants ¶
This section is empty.
Variables ¶
var ErrMissingCatalogBase error = MissingCatalogBaseError{}
ErrMissingCatalogBase is the zero-value sentinel for errors.Is.
var ErrNotAManifest error = NotAManifestError{}
var ErrNotAnImageIndex error = NotAnImageIndexError{}
var ErrUnexpectedMediaType error = UnexpectedMediaTypeError{}
var ErrUnsupportedPlatform error = UnsupportedPlatformError{}
Functions ¶
func IsRelative ¶
IsRelative reports whether ref lacks a registry/repository base — i.e. it is empty, or begins with ":" (tag) or "@" (digest).
func JoinRef ¶
JoinRef appends reference to a repository with the separator the reference implies: "@" for a digest, ":" for a tag.
func OpenArchive ¶
func OpenArchive(ctx context.Context, c Client, ref string, platform Platform) (io.ReadCloser, int64, error)
OpenArchive pulls ref (which must be an OCI Image Index), selects the entry matching platform, fetches that per-platform manifest, and streams its single layer blob.
func OpenSource ¶
OpenSource pulls ref (which must be a plain image manifest) and streams its single layer blob. Source is platform-independent, so there is no selection.
func PullArtifactBytes ¶
PullArtifactBytes pulls the single-layer image manifest at ref, verifies the top manifest against ref's digest when ref is digest-pinned, rejects an image index, requires the layer's media type to equal wantMediaType, verifies the layer blob against its descriptor (digest + size), and returns the fully-read bytes. Pass wantMediaType == "" to skip the media-type check.
func ResolveRef ¶
ResolveRef turns an authored oci.ref template into an absolute ref template (still containing any {{.Version}} placeholder). kind is "archives" or "sources"; base is the catalog base ("" when none is available). A relative ref with no base yields MissingCatalogBaseError.
func SplitRef ¶
SplitRef splits an absolute reference "<name>[:<tag>][@<digest>]" into the repository name and the reference (digest if present, else tag). A registry port colon (e.g. "localhost:5000/foo") is not mistaken for a tag.
func WithDefaultTag ¶
WithDefaultTag appends ":{{.Version}}" when ref carries neither a tag nor a digest. An empty ref becomes the bare default tag.
Types ¶
type Client ¶
type Client interface {
// PullManifest fetches the manifest addressed by ref (its tag or digest).
PullManifest(ctx context.Context, ref string) ([]byte, ocispec.Descriptor, error)
// PullManifestByDigest fetches a manifest by digest from ref's repository.
PullManifestByDigest(ctx context.Context, ref, digest string) ([]byte, error)
// PullBlob fetches a blob described by target from ref's repository.
PullBlob(ctx context.Context, ref string, target ocispec.Descriptor) (io.ReadCloser, int64, error)
}
Client is the minimal ORAS surface OpenArchive/OpenSource need. Every method is scoped to the repository named in ref.
func NewClient ¶
func NewClient(cred CredentialFunc, opts ...Option) Client
NewClient builds a Client that pulls from OCI registries using cred.
type CredentialFunc ¶
CredentialFunc returns registry credentials for a host, in oras-go's shape.
func Keychain ¶
func Keychain(resolver auth.Resolver) CredentialFunc
Keychain composes credentials: the Docker credential store first, then the nem resolver's per-registry fallback, then anonymous. The Docker store loads lazily and memoized; a load failure degrades to the nem/anonymous path.
type MissingCatalogBaseError ¶
type MissingCatalogBaseError struct {
Package string
}
MissingCatalogBaseError reports a relative oci.ref used where no catalog base is available to resolve it (e.g. a git or local-dir catalog).
func (MissingCatalogBaseError) Error ¶
func (e MissingCatalogBaseError) Error() string
func (MissingCatalogBaseError) Is ¶
func (e MissingCatalogBaseError) Is(target error) bool
type NotAManifestError ¶
type NotAManifestError struct{ Ref, Got string }
NotAManifestError reports that a source ref resolved to an image index rather than a plain image manifest.
func (NotAManifestError) Error ¶
func (e NotAManifestError) Error() string
func (NotAManifestError) Is ¶
func (e NotAManifestError) Is(target error) bool
type NotAnImageIndexError ¶
type NotAnImageIndexError struct{ Ref, Got string }
NotAnImageIndexError reports that an archive ref resolved to a media type other than an OCI image index.
func (NotAnImageIndexError) Error ¶
func (e NotAnImageIndexError) Error() string
func (NotAnImageIndexError) Is ¶
func (e NotAnImageIndexError) Is(target error) bool
type Option ¶
type Option func(*realClient)
Option configures a Client built by NewClient.
func WithPlainHTTP ¶
func WithPlainHTTP() Option
WithPlainHTTP makes the client use http:// (for local registries / tests).
type UnexpectedMediaTypeError ¶
UnexpectedMediaTypeError reports that a single-layer artifact's layer carried a media type other than the one the caller required.
func (UnexpectedMediaTypeError) Error ¶
func (e UnexpectedMediaTypeError) Error() string
func (UnexpectedMediaTypeError) Is ¶
func (e UnexpectedMediaTypeError) Is(target error) bool
type UnsupportedPlatformError ¶
UnsupportedPlatformError reports that an image index contained no entry matching the requested platform.
func (UnsupportedPlatformError) Error ¶
func (e UnsupportedPlatformError) Error() string
func (UnsupportedPlatformError) Is ¶
func (e UnsupportedPlatformError) Is(target error) bool