Documentation
¶
Overview ¶
Package registry implements the storage layer of the Epoch OCI registry.
It is intentionally vendor-agnostic: cocoonstack-specific concepts (cloud images, snapshots) live in the [snapshot] and [cloudimg] packages on top of these primitives. The registry only knows how to store and retrieve blobs and manifests in an S3-compatible object store, plus maintain a global catalog index for the control-plane API.
Object layout in the bucket (under the configured prefix, default `epoch/`):
catalog.json — global repository index manifests/<name>/<tag>.json — manifest by tag manifests/<name>/_digests/<dgst>.json — manifest by content digest blobs/sha256/<dgst> — content-addressable blob
All blobs are stored under their unprefixed hex digest. Callers that have a `sha256:<hex>` form must strip the prefix before calling Registry.StreamBlob, [Registry.PullBlob], etc.
Index ¶
- type Registry
- func (r *Registry) BlobExists(ctx context.Context, digest string) (bool, error)
- func (r *Registry) BlobSize(ctx context.Context, digest string) (int64, error)
- func (r *Registry) DeleteBlob(ctx context.Context, digest string) error
- func (r *Registry) DeleteManifest(ctx context.Context, name, tag string) error
- func (r *Registry) GetCatalog(ctx context.Context) (*manifest.Catalog, error)
- func (r *Registry) GetCatalogWithDigest(ctx context.Context) (*manifest.Catalog, string, error)
- func (r *Registry) ListTags(ctx context.Context, name string) ([]string, error)
- func (r *Registry) ManifestJSON(ctx context.Context, name, tag string) ([]byte, error)
- func (r *Registry) ManifestJSONByDigest(ctx context.Context, name, digest string) ([]byte, error)
- func (r *Registry) PushBlobFromStream(ctx context.Context, digest string, body io.Reader, size int64) error
- func (r *Registry) PushManifestJSON(ctx context.Context, name, tag string, data []byte) error
- func (r *Registry) PushManifestJSONByDigest(ctx context.Context, name string, data []byte) (string, error)
- func (r *Registry) StreamBlob(ctx context.Context, digest string) (io.ReadCloser, int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the storage facade for an Epoch OCI registry. It is safe for concurrent use.
func New ¶
func New(client *objectstore.Client) *Registry
New creates a registry backed by the given object store client.
func NewFromEnv ¶
NewFromEnv creates a registry using object store credentials from the environment.
func (*Registry) BlobExists ¶
BlobExists checks if a blob exists. The digest must be unprefixed hex.
func (*Registry) DeleteBlob ¶
DeleteBlob removes a blob from the object store.
func (*Registry) DeleteManifest ¶
DeleteManifest removes a manifest tag and updates the catalog. The content-addressed copy under `_digests/` is intentionally left in place so re-tagging by digest still works.
func (*Registry) GetCatalog ¶
GetCatalog returns the global catalog.
func (*Registry) GetCatalogWithDigest ¶ added in v0.1.7
GetCatalogWithDigest returns the catalog together with the SHA-256 digest of its raw JSON.
func (*Registry) ListTags ¶
ListTags returns all tags for a repository. Manifests stored under the per-name `_digests/` subdirectory (the by-digest copies) are skipped — they are content-addressed pointers to the same data, not user-facing tags.
func (*Registry) ManifestJSON ¶
ManifestJSON returns the raw JSON bytes of a manifest looked up by tag.
func (*Registry) ManifestJSONByDigest ¶ added in v0.1.7
ManifestJSONByDigest returns the raw JSON bytes of a manifest looked up by content digest. OCI clients (go-containerregistry, docker, buildah) push by tag and then re-fetch by digest after resolving — this read path is what closes that loop.
func (*Registry) PushBlobFromStream ¶
func (r *Registry) PushBlobFromStream(ctx context.Context, digest string, body io.Reader, size int64) error
PushBlobFromStream uploads a blob whose digest the caller has already computed. The digest must be the unprefixed lowercase hex SHA-256. Existing blobs are deduplicated.
func (*Registry) PushManifestJSON ¶
PushManifestJSON uploads a manifest from raw JSON bytes and updates the catalog. The bytes are written under both the tag key and the content digest key, so the manifest can later be fetched by either reference. The digest write happens first (it is idempotent and content-addressed), so a failure between writes leaves no dangling tag pointer.
func (*Registry) PushManifestJSONByDigest ¶ added in v0.1.7
func (r *Registry) PushManifestJSONByDigest(ctx context.Context, name string, data []byte) (string, error)
PushManifestJSONByDigest stores a manifest under its content digest only. Unlike PushManifestJSON it neither writes a tag entry nor touches the catalog: by-digest pushes are how OCI clients pre-load child manifests of a multi-arch image index before pushing the index itself by tag, and recording each child as a tag would pollute the catalog with sha256:* entries that are not user-visible references.
Returns the computed `sha256:<hex>` digest so the caller can echo it in the response and verify it against a digest reference if present.
func (*Registry) StreamBlob ¶
StreamBlob returns a streaming reader for a blob and its size. Caller must close the returned ReadCloser. The digest must be unprefixed hex.