Documentation ¶
Overview ¶
Package registry provides high-level operations to manage registries.
Index ¶
- func Repositories(ctx context.Context, reg Registry) ([]string, error)
- func Tags(ctx context.Context, repo Repository) ([]string, error)
- type BlobStore
- type ManifestStore
- type Reference
- func (r Reference) Digest() (digest.Digest, error)
- func (r Reference) Host() string
- func (r Reference) ReferenceOrDefault() string
- func (r Reference) String() string
- func (r Reference) Validate() error
- func (r Reference) ValidateReference() error
- func (r Reference) ValidateRegistry() error
- func (r Reference) ValidateRepository() error
- type ReferenceFetcher
- type ReferencePusher
- type ReferrerFinder
- type Registry
- type Repository
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Repositories ¶
Repositories lists the name of repositories available in the registry.
Example ¶
ExampleRepositories gives example snippets for listing respositories in the registry without pagination.
reg, err := remote.NewRegistry(host) if err != nil { panic(err) // Handle error } ctx := context.Background() repos, err := registry.Repositories(ctx, reg) if err != nil { panic(err) // Handle error } for _, repo := range repos { fmt.Println(repo) }
Output: public/repo1 public/repo2 internal/repo3
Types ¶
type ManifestStore ¶
type ManifestStore interface { BlobStore content.Tagger ReferencePusher }
ManifestStore is a CAS with the ability to stat and delete its content. Besides, ManifestStore provides reference tagging.
type Reference ¶
type Reference struct { // Registry is the name of the registry. // It is usually the domain name of the registry optionally with a port. Registry string // Repository is the name of the repository. Repository string // Reference is the reference of the object in the repository. // A reference can be a tag or a digest. Reference string }
Reference references to a descriptor in the registry.
func ParseReference ¶
ParseReference parses a string (artifact) into an `artifact reference`.
Note: An "image" is an "artifact", however, an "artifact" is not necessarily an "image".
The parameter `artifact` is an opaque polymorphic string, composed of two other opaque tokens; namely `socketaddr` and `path`: These can in turn take on their own polymorphic forms. To do this, the Backus–Naur Form (BNF) notation has been adopted, with the exception that *lowercase* labels here imply opaque values (composed of other components), and *uppercase* labels imply resolute/final values (can not be expanded further into subcomponents).
<artifact> ::= <socketaddr> "/" <path> <socketaddr> ::= <host> | <host> ":" <PORT> <host> ::= <ip> | <FQDN> <ip> ::= <IPV4-ADDR> | <IPV6-ADDR> <path> ::= <REPOSITORY> | <REPOSITORY> <reference> <reference> ::= "@" <digest> | ":" <TAG> "@" <DIGEST> | ":" <TAG> <digest> ::= <ALGO> ":" <HASH>
That is, of all the possible forms that `path` can take, there are exactly 4 that are considered valid. Expanding the BNF notation for `path`, the 4 are:
<---------------------- path ----------------------> | - Decode `path` <=== REPOSITORY ===><---------- reference ---------> | - Decode `reference` <=== REPOSITORY ===><=================== digest ===> | - Valid Form A <=== REPOSITORY ===><!!! TAG !!!> @ <=== digest ===> | - Valid Form B <=== REPOSITORY ===><=== TAG ======================> | - Valid Form C <=== REPOSITORY ===================================> | - Valid Form D
Note: In the case of Valid Form B, TAG is dropped without any validation or further consideration.
func (Reference) ReferenceOrDefault ¶
ReferenceOrDefault returns the reference or the default reference if empty.
func (Reference) String ¶
String implements `fmt.Stringer` and returns the reference string. The resulted string is meaningful only if the reference is valid.
func (Reference) ValidateReference ¶
ValidateReference validates the reference.
func (Reference) ValidateRegistry ¶
ValidateRegistry validates the registry.
func (Reference) ValidateRepository ¶
ValidateRepository validates the repository.
type ReferenceFetcher ¶
type ReferenceFetcher interface { // FetchReference fetches the content identified by the reference. FetchReference(ctx context.Context, reference string) (ocispec.Descriptor, io.ReadCloser, error) }
ReferenceFetcher provides advanced fetch with the tag service.
type ReferencePusher ¶
type ReferencePusher interface { // PushReference pushes the manifest with a reference tag. PushReference(ctx context.Context, expected ocispec.Descriptor, content io.Reader, reference string) error }
ReferencePusher provides advanced push with the tag service.
type ReferrerFinder ¶
type ReferrerFinder interface {
Referrers(ctx context.Context, desc ocispec.Descriptor, artifactType string, fn func(referrers []artifactspec.Descriptor) error) error
}
ReferrerFinder provides the Referrers API. Reference: https://github.com/oras-project/artifacts-spec/blob/main/manifest-referrers-api.md
type Registry ¶
type Registry interface { // Repositories lists the name of repositories available in the registry. // Since the returned repositories may be paginated by the underlying // implementation, a function should be passed in to process the paginated // repository list. // `last` argument is the `last` parameter when invoking the catalog API. // If `last` is NOT empty, the entries in the response start after the // repo specified by `last`. Otherwise, the response starts from the top // of the Repositories list. // Note: When implemented by a remote registry, the catalog API is called. // However, not all registries supports pagination or conforms the // specification. // Reference: https://docs.docker.com/registry/spec/api/#catalog // See also `Repositories()` in this package. Repositories(ctx context.Context, last string, fn func(repos []string) error) error // Repository returns a repository reference by the given name. Repository(ctx context.Context, name string) (Repository, error) }
Registry represents a collection of repositories.
type Repository ¶
type Repository interface { content.Storage content.Deleter content.TagResolver ReferenceFetcher ReferencePusher // Blobs provides access to the blob CAS only, which contains config blobs, // layers, and other generic blobs. Blobs() BlobStore // Manifests provides access to the manifest CAS only. Manifests() ManifestStore // Tags lists the tags available in the repository. // Since the returned tag list may be paginated by the underlying // implementation, a function should be passed in to process the paginated // tag list. // `last` argument is the `last` parameter when invoking the tags API. // If `last` is NOT empty, the entries in the response start after the // tag specified by `last`. Otherwise, the response starts from the top // of the Tags list. // Note: When implemented by a remote registry, the tags API is called. // However, not all registries supports pagination or conforms the // specification. // References: // - https://github.com/opencontainers/distribution-spec/blob/main/spec.md#content-discovery // - https://docs.docker.com/registry/spec/api/#tags // See also `Tags()` in this package. Tags(ctx context.Context, last string, fn func(tags []string) error) error }
Repository is an ORAS target and an union of the blob and the manifest CASs. As specified by https://docs.docker.com/registry/spec/api/, it is natural to assume that content.Resolver interface only works for manifests. Tagging a blob may be resulted in an `ErrUnsupported` error. However, this interface does not restrict tagging blobs. Since a repository is an union of the blob and the manifest CASs, all operations defined in the `BlobStore` are executed depending on the media type of the given descriptor accordingly. Furthermore, this interface also provides the ability to enforce the separation of the blob and the manifests CASs.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
doc
Package doc provides the constant can be used in example test files.
|
Package doc provides the constant can be used in example test files. |
Package remote provides a client to the remote registry.
|
Package remote provides a client to the remote registry. |
auth
Package auth provides authentication for a client to a remote registry.
|
Package auth provides authentication for a client to a remote registry. |