Documentation
¶
Overview ¶
Package registry runs the Docker registry's blob uploads (decision 0031). A session spans requests and survives a restart: it is a row in the uploads table under Backend, naming the blob store upload it appends to, and its repository, image and user, which alone may continue it. A finished upload, whether chunked, monolithic or mounted from another image, becomes the item <image>/_uploads/sha256__<hex> through the item service, where a manifest push finds it. The garbage collector hands stale sessions to Reap and asks ExpireUploads for finished uploads no manifest took in time.
Index ¶
- Constants
- Variables
- type BlobsUnknownError
- type Owner
- type Parent
- type PlatformTag
- type Promotion
- type Push
- type Removal
- type Rename
- type Service
- func (s *Service) Append(ctx context.Context, o Owner, id string, offset int64, body io.Reader) (int64, error)
- func (s *Service) Begin(ctx context.Context, o Owner) (string, error)
- func (s *Service) Cancel(ctx context.Context, o Owner, id string) error
- func (s *Service) DeleteManifest(ctx context.Context, o Owner, hex string) error
- func (s *Service) DeleteMultiArch(ctx context.Context, o Owner, tag string) ([]string, error)
- func (s *Service) DeleteTag(ctx context.Context, o Owner, tag string) error
- func (s *Service) ExpireUploads(ctx context.Context, before time.Time) (int, error)
- func (s *Service) Finish(ctx context.Context, o Owner, id string, offset int64, body io.Reader, ...) (types.Item, error)
- func (s *Service) Mount(ctx context.Context, o Owner, src repo.Config, srcName, hex string) (types.Item, bool, error)
- func (s *Service) ParentManifests(ctx context.Context, o Owner, tag string) ([]Parent, error)
- func (s *Service) Promote(ctx context.Context, p Promotion) error
- func (s *Service) PromotedTags(ctx context.Context, o Owner, tag string) ([]string, error)
- func (s *Service) PutManifest(ctx context.Context, p Push) error
- func (s *Service) Reap(ctx context.Context, u store.Upload) error
- func (s *Service) Referrers(ctx context.Context, o Owner, subject, artifactType string) ([]layout.Descriptor, error)
- func (s *Service) RemoveTag(ctx context.Context, o Owner, tag string, r Removal) error
- func (s *Service) Replaces(ctx context.Context, o Owner, folder, hex string) (bool, error)
- func (s *Service) Status(ctx context.Context, o Owner, id string) (int64, error)
- func (s *Service) TagManifest(ctx context.Context, o Owner, tag string) (types.Item, error)
- func (s *Service) UnreferencedPlatforms(ctx context.Context, o Owner, folder string) ([]string, error)
- func (s *Service) Upload(ctx context.Context, o Owner, body io.Reader, hex string) (types.Item, error)
- type SizeMismatch
- type SizeMismatchError
Constants ¶
const Backend = "docker"
Backend names registry sessions in the uploads table, so the garbage collector hands them to Reap rather than to the blob store.
Variables ¶
var ( // ErrUnknown is a session that never existed, has ended, or belongs to // another repository, image or user: BLOB_UPLOAD_UNKNOWN. ErrUnknown = errors.New("registry: unknown upload session") // ErrOffset is a chunk that does not start where the session ends. // Nothing was read; the client resumes from the session's size. ErrOffset = errors.New("registry: chunk out of order") // ErrDigest is content whose SHA-256 is not the declared digest. The // session, if any, is discarded. ErrDigest = errors.New("registry: digest mismatch") )
var ErrSamePlace = errors.New("registry: the source and the target are the same")
ErrSamePlace is a promotion onto itself: the same repository, image and tag.
Functions ¶
This section is empty.
Types ¶
type BlobsUnknownError ¶
type BlobsUnknownError struct {
Digests []string
}
BlobsUnknownError is a manifest that references blobs the image does not hold: MANIFEST_BLOB_UNKNOWN, once for each digest.
func (*BlobsUnknownError) Error ¶
func (e *BlobsUnknownError) Error() string
type Owner ¶
type Owner struct {
Repo repo.Config
// Name is the image inside Repo.
Name string
// By is the user that opened it.
By string
}
Owner is who a session belongs to.
type Parent ¶
Parent is a manifest list or image index that names a given manifest, with the tags it is pushed under.
type PlatformTag ¶
PlatformTag is a descriptive tag a list push adds for one of its platforms (decision 0031), and the SHA-256 of the platform manifest it holds.
func PlatformTags ¶
func PlatformTags(m layout.Manifest, tag string) []PlatformTag
PlatformTags returns the descriptive tags that the list m adds when it is pushed to tag: <tag>-<os>-<architecture> for each entry that names a platform, as 7.x adds them from 7.21.2 (docker-repositories, "Multi-Architecture Tagging"; RTFACT-26257). A variant is not part of the name, which the documentation gives as the os and architecture alone, so entries that differ only in variant share one tag [I]. Each name is returned once, holding the last entry that gives it, as tagging the entries in order would leave it [I]; a name outside the tag grammar, as when tag is near the 128-character limit, is left out. An image manifest, and an entry with no platform or a digest under another algorithm, give none.
type Promotion ¶
Promotion is a JFrog Docker promote (decision 0031): tags of From's image copied or moved to To's image, which may be in another repository of the same package type, under another name. To.By is who promotes.
type Push ¶
type Push struct {
Owner
Manifest layout.Manifest
// Body is the manifest exactly as the client sent it, which jf reads
// back to take the config's digest (research 23, 5.1).
Body []byte
// Folders are where it is stored, each a direct child of the image: a
// tag, or the digest folder with any tags pushed alongside it.
Folders []string
}
Push is a manifest to store in an image.
type Removal ¶
type Removal struct {
// Platforms removes, with a manifest list or image index, its
// descriptive platform tags and the digest folders of its platform
// manifests that no list left in the image names (decision 0031).
Platforms bool
// Retained removes the tag's previous manifests that Tag Retention kept.
Retained bool
// Twin removes the tag's digest twin when nothing else keeps it
// (loneTwin).
Twin bool
}
Removal says what goes with a tag that RemoveTag removes.
type Service ¶
type Service struct {
Store store.Store
Blobs blob.Store
// Now supplies the time; nil means time.Now.
Now func() time.Time
// Formats and Work reach the item service's format hooks (decision
// 0032); nil means formats.For and the store's queue.
Formats func(repo.PackageType) format.Handler
Work item.Enqueuer
// contains filtered or unexported fields
}
Service runs registry uploads over a metadata store and its blob store.
func (*Service) Append ¶
func (s *Service) Append( ctx context.Context, o Owner, id string, offset int64, body io.Reader, ) (int64, error)
Append adds body to session id and returns the session's size. offset is where the client says the chunk starts, or negative when it sent no range; a chunk that does not start at the session's end is refused with ErrOffset before any of it is read. The body streams through to the blob store, so a layer is never held in memory.
func (*Service) DeleteManifest ¶
DeleteManifest removes every folder of o's image that holds the manifest whose SHA-256 is hex, its tag folders and its digest folder, in one transaction, so that neither the digest nor a tag that named it answers afterwards. An index's platform manifests stay: they are manifests of their own. store.ErrNotFound when no folder holds it.
func (*Service) DeleteMultiArch ¶
DeleteMultiArch removes the tag folder of o's image together with its descriptive platform tags and the platform manifests UnreferencedPlatforms names, in one transaction, sending them to the trash can when it is on (decision 0010), by o.By: 7.x deletes the tag "with all of their sub-architectures". It returns the folders removed, the tag first; store.ErrNotFound when the image has no such tag. The caller has checked Delete on the image, which covers its digest folders. DELETE /artifactory/api/docker/<repo>/v2/delete (#226) calls it.
func (*Service) DeleteTag ¶
DeleteTag removes the tag folder of o's image with everything in it, as RemoveTag does with nothing else: its files go to the trash can when it is on and the package index follows (decisions 0018 and 0031). The manifest stays readable by digest from any other folder holding it. store.ErrNotFound when the folder holds no manifest.
func (*Service) ExpireUploads ¶
ExpireUploads removes the finished uploads last written before before from every repository that holds images, and returns how many it removed. A manifest push links the blobs it references into its own folder, so an upload no manifest took by then was abandoned (decision 0031). They bypass the trash can: nobody deployed them as files.
func (*Service) Finish ¶
func (s *Service) Finish( ctx context.Context, o Owner, id string, offset int64, body io.Reader, hex string, ) (types.Item, error)
Finish appends the last chunk, if body holds one, verifies the content against the SHA-256 hex, and stores it as the image's finished upload. A mismatch discards the session (ErrDigest).
func (*Service) Mount ¶
func (s *Service) Mount( ctx context.Context, o Owner, src repo.Config, srcName, hex string, ) (types.Item, bool, error)
Mount links the blob hex from the image srcName in src into o's image as a finished upload, by reference to the stored content: no bytes are copied. ok is false when the source image does not hold the blob, or its content went meanwhile, and the registry then opens a session instead. The caller checks that o may read the source.
func (*Service) ParentManifests ¶
ParentManifests returns the manifest lists and image indexes of o's image that name the manifest tag holds (decision 0031), each once with the tags it sits under, ordered by digest. A push stores a list only where its platforms already are, so the image is all there is to search. store.ErrNotFound when tag holds no manifest.
func (*Service) Promote ¶
Promote lands each of p's tags in p.To through the item service, so the trash can, the package index and events follow as for any copy or move; the caller has checked permissions. A tag folder lands with its blobs linked, never copied as bytes, and a manifest list takes its platform manifests' digest folders along. A target tag holding another manifest is replaced as a push replaces it, keeping it under Tag Retention, and the target image's tag limits apply afterwards. Without p.Copy each tag folder moves, keeping its history, and the platform manifests nothing left in the source image names go too. All of it is one transaction.
func (*Service) PromotedTags ¶
PromotedTags returns the tags a promotion of o's image takes: tag alone, or every tag of the image when tag is empty. store.ErrNotFound when the image holds no tag, or tag names no folder holding a manifest.
func (*Service) PutManifest ¶
PutManifest stores p's manifest in each of its folders (decision 0031): the exact bytes as manifest.json, or list.manifest.json for an index or manifest list, with the properties jf and Docker clients read, and an image's config and layers linked beside it by reference to their stored content, never copied. Every blob an image needs, and every manifest an index lists, must already be in the image (a *BlobsUnknownError otherwise); a subject need not be. A folder holding the same manifest is left as it is; one holding another manifest, or anything else, is replaced, keeping a tag's previous manifest under Tag Retention. A list pushed to a tag also gets its descriptive platform tags (PlatformTags). The repository's tag limits then apply to the image, all in one transaction.
func (*Service) Reap ¶
Reap discards a stale session for the garbage collector: its blob store upload, when that still exists, then its row.
func (*Service) Referrers ¶
func (s *Service) Referrers( ctx context.Context, o Owner, subject, artifactType string, ) ([]layout.Descriptor, error)
Referrers returns the descriptors of the manifests in o's image whose subject is the digest subject, of artifactType alone when it is set: what GET .../referrers/<digest> lists (decision 0031). Each manifest appears once whichever folders hold it, sorted by digest, with the media type it was pushed with, its size, its artifactType and its annotations. None is an empty list, never an error: the referrers API answers no 404.
func (*Service) RemoveTag ¶
RemoveTag removes the tag folder of o's image through the item service: its files go to the trash can when it is on, and the package index (decision 0018) drops the version in the same transaction, so a caller keeps nothing in step itself. A manifest DELETE by tag removes with no Removal, the multi-architecture delete with Platforms, and Max Unique Tags with all three. store.ErrNotFound when the image has no such tag.
func (*Service) Replaces ¶
Replaces reports whether storing the manifest whose SHA-256 is hex in folder of o's image would replace what the folder holds: a different manifest, or files of any kind. Replacing needs Delete as well as Deploy (DV-035); pushing the manifest a folder already holds changes nothing, so a client repeating a push needs no more than Deploy.
func (*Service) TagManifest ¶
TagManifest is the manifest file tag holds in o's image; store.ErrNotFound for a reserved name, a digest folder or a folder holding none.
func (*Service) UnreferencedPlatforms ¶
func (s *Service) UnreferencedPlatforms( ctx context.Context, o Owner, folder string, ) ([]string, error)
UnreferencedPlatforms returns the digest folders, below o's image, of the platform manifests that the list manifest in folder lists and that no other tag folder holds and no other index in the image lists: what deleting the multi-architecture tag also removes, as Artifactory does from 7.118.0 (decision 0031), and what tag retention removes with a list manifest. The list's own descriptive tags (PlatformTags) go with it, so they keep nothing. A folder holding an image manifest, or nothing, has none. The list's own digest folder, when it was pushed by digest too, is another index that lists them, so its platforms stay.
type SizeMismatch ¶
SizeMismatch is one descriptor whose size differs from the stored content.
type SizeMismatchError ¶
type SizeMismatchError struct {
Mismatches []SizeMismatch
}
SizeMismatchError is a manifest whose descriptors give sizes other than the stored content's: MANIFEST_INVALID, once for each. Docker's reference registry checks only that the content exists, but a client trusting the size reads past or stops short of it (the image specification: such content "SHOULD NOT be trusted"), so the push is refused (decision 0031).
func (*SizeMismatchError) Error ¶
func (e *SizeMismatchError) Error() string