|
1 | 1 | # Client Implementations |
2 | 2 |
|
3 | | -The distribution-spec is mainly concerned with registry behaviour. However, |
4 | | -some registries may not always support all aspects of the spec. |
| 3 | +This document describes client implementation recommendations for interoperability with registry servers and other clients using the OCI Distribution Spec. |
5 | 4 |
|
6 | | -This document is a guide for clients that wish to add backwards compaitibility |
7 | | -for registries which only use older endpoints. |
| 5 | +## Backwards Compatibility |
8 | 6 |
|
9 | | -For the remainder of this document "referrers API" will refer to [end-12](TODO), |
10 | | -and the use of reference types. |
| 7 | +Client implementations SHOULD support registries that implement partial or older versions of the OCI Distribution Spec. |
| 8 | +This section describes how client fallback procedures when an API is not available. |
11 | 9 |
|
12 | | -## Digest Tags |
| 10 | +### Referrers API |
13 | 11 |
|
14 | | -For registries that do not support the referrers API, a tag MUST be pushed containing an index of all manifests that refer to the specified manifest, matching the API response above. |
15 | | -The tag uses the following schema: |
| 12 | +The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12](spec.md#endpoints). |
| 13 | + |
| 14 | +A client that pushing an Image or Artifact manifest with a defined `Refers` field MUST verify the Referrers API is available. |
| 15 | +A client querying the Referrers API and receiving a 404 MUST fallback to using an Index pushed to a tag described by the following schema. |
| 16 | + |
| 17 | +**Tag Schema** |
16 | 18 |
|
17 | 19 | ```text |
18 | 20 | <alg>-<ref> |
19 | 21 | ``` |
20 | 22 |
|
21 | | -- E.g. `registry.example.org/project:sha256-0000000000000000000000000000000000000000000000000000000000000000` |
22 | | -- `<alg>`: the digest algorithm |
| 23 | +- `<alg>`: the digest algorithm (e.g. `sha256` or `sha512`) |
23 | 24 | - `<ref>`: the digest from the `refers` field (limit of 64 characters) |
24 | | -- Periodic garbage collection may be performed by clients pushing new referrers, deleting stale referrers that have been replaced with newer versions, and tags that no longer point to an accessible manifest. |
25 | | -- Clients can verify the registry does not support the referrers API by querying the API and checking for a 404. |
26 | | -- Clients should pull the existing tag and extend it with additional entries, minimizing the time between the pull and push to reduce the chance of overwriting changes from other clients. |
27 | | -- Clients should use a conditional push for registries that support ETag conditions to avoid overwriting a tag that has been modified by another client since the previous tag manifest was pulled. |
28 | 25 |
|
29 | | -## Client Expectations |
| 26 | +For example, a manifest with the `Refers` field digest set to `sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` in the `registry.example.org/project` repository would have a expect an Index at `registry.example.org/project:sha256-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` |
| 27 | + |
| 28 | +**Pushing Manifests** |
| 29 | + |
| 30 | +When pushing an Image or Artifact manifest with the `Refers` field and the Referrers API returns a 404, the client MUST: |
30 | 31 |
|
31 | | -### Creating Artifacts |
| 32 | +1. Pull the Index using the tag schema. |
| 33 | +1. If the tag returns a manifest other than the expected Index, the client SHOULD report a failure and skip the remaining steps. |
| 34 | +1. If the tag returns a 404, the client MUST begin with an empty Index. |
| 35 | +1. Verify the descriptor for the manifest is not already in the Index (duplicate entries SHOULD NOT be created). |
| 36 | +1. Append a descriptor for the pushed manifest to the Index manifests. |
| 37 | + The value of the `artifactType` MUST be set in the descriptor to value of the `artifactType` in the Artifact manifest, or the Config descriptor `mediaType` in the Image manifest. |
| 38 | + All annotations from the Image or Artifact manifest MUST be copied to this descriptor. |
| 39 | +1. Push the updated Index using the same tag schema. |
| 40 | + The client MAY use conditional HTTP requests to prevent overwriting an Index that has changed since it was first pulled. |
32 | 41 |
|
33 | | -- For portability, clients should generate artifacts using image-spec until all registries where the artifact is pushed to have been upgraded. |
34 | | -- The descriptor of the manifest this artifact refers to should be set in the `refers` field of the manifest. |
35 | | -- Other metadata should be included in the manifest annotations. |
36 | | -- When pushing, the registry should be checked for the referrers API support. |
37 | | -- If the referrers API is not available, the artifact should be pushed with a tag using the digest schema. Tags with the digest schema should not be pushed if the referrers API is available. |
| 42 | +**Listing Referrers** |
38 | 43 |
|
39 | | -### Pulling Artifacts |
| 44 | +If the Referrers API returns a 404, the client MUST fallback to pulling the tag schema. |
| 45 | +The response SHOULD be an Index with the same content that would be expected from the Referrers API. |
| 46 | +If the response to the Referrers API is a 404, and the tag schema does not return a valid Index, the client SHOULD assume there are no Referrers to the manifest. |
40 | 47 |
|
41 | | -To pull artifacts that reference an existing manifest: |
| 48 | +**Deleting Referrers** |
42 | 49 |
|
43 | | -- Clients requests artifacts associated with a manifest first query the referrers API using the digest of the requested manifest. |
44 | | -- If the request fails, clients must fall back to listing tags in the repository and pull manifests for each tag with the matching `<alg>` and `<ref>` prefix. |
45 | | -- Clients then pull any artifact matching their criteria from the API response or the list generated from the tag query. |
| 50 | +When deleting an Image or Artifact manifest that contains a `Refers` field, and the Referrers API returns a 404, clients SHOULD: |
46 | 51 |
|
47 | | -### Copying Images |
| 52 | +1. Pull the Index using the tag schema. |
| 53 | +1. Delete the descriptor from the manifest list to the deleted manifest. |
| 54 | +1. Push the updated Index using the same tag schema. |
| 55 | + The client MAY use conditional HTTP requests to prevent overwriting an Index that has changed since it was first pulled. |
48 | 56 |
|
49 | | -- Tooling that copies images between registries may recursively query for referrers and copy them. |
50 | | -- Copying an artifact that refers to an image uses the same pull and push steps described above and should support both existing registries and registries with the referrers API on both the pull and push. |
| 57 | +**Deleting Manifests** |
51 | 58 |
|
52 | | -### Deleting Manifests |
| 59 | +Clients MAY delete a tag using the tag schema when it returns a valid Index manifest and the referred manifest has been deleted. |
53 | 60 |
|
54 | | -For managing existing registries without the referrers API: |
| 61 | +**Recommendations** |
55 | 62 |
|
56 | | -- Client tooling that deletes manifests should also delete digest tags that reference that manifest. |
57 | | -- Client tooling may periodically check for dangling digest tags that refer to missing manifest, and prune those tags. |
| 63 | +- Clients MAY verify the registry does not support the referrers API by querying the API and checking for a 404. |
| 64 | +- When the Referrers API is not available, clients MAY perform periodic garbage collection of stale tag schema tags and descriptors in the Index manifest list that no longer exist. |
| 65 | +- Clients MAY use a conditional HTTP push for registries that support ETag conditions to avoid conflicts with other clients. |
| 66 | +- For portability, clients MAY generate artifacts using image-spec until all registries where the artifact is pushed to have been upgraded. |
| 67 | +- Tooling that copies images between registries MAY recursively query for referrers and copy them. |
0 commit comments