Skip to content

Commit e6c3cd3

Browse files
authored
Merge pull request opencontainers#9 from michaelb990/mb/add-filtering
Add filtering to references API
2 parents b9b48f8 + 70c70b5 commit e6c3cd3

File tree

3 files changed

+52
-19
lines changed

3 files changed

+52
-19
lines changed

client-implementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This section describes how client fallback procedures when an API is not availab
99

1010
### Referrers API
1111

12-
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12](spec.md#endpoints).
12+
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12a](spec.md#endpoints).
1313

1414
A client that pushes an Image or Artifact manifest with a defined `Refers` field MUST verify the Referrers API is available.
1515
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.

spec.md

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ When using the `last` query parameter, the `n` parameter is OPTIONAL.
496496
Clients should see [client-implementation.md](client-implementation.md) for more details on implementing this.
497497
Registries should see [upgrading.md](upgrading.md) before enabling this.*
498498

499-
To fetch the list of referrers, perform a `GET` request to a path in the following format: `/v2/<name>/referrers/<reference>` <sup>[end-12](#endpoints)</sup>
499+
To fetch the list of referrers, perform a `GET` request to a path in the following format: `/v2/<name>/referrers/<reference>` <sup>[end-12a](#endpoints)</sup>
500500

501501
`<name>` is the namespace of the repository.
502502
Assuming a repository is found, this request MUST return a `200 OK` response code.
@@ -535,6 +535,38 @@ Upon success, the response MUST be a json body in the following format (an index
535535
A `Link` header MUST be included in the response when additional results are available.
536536
The `Link` header MUST be set according to [RFC5988](https://www.rfc-editor.org/rfc/rfc5988.html) with the Relation Type `rel="next"`.
537537

538+
The registry SHOULD support filtering on `artifactType`<sup>[end-12b](#endpoints)</sup>.
539+
If filtering is requested and applied, the response MUST include an annotation (`org.opencontainers.references.filtersApplied`) denoting that an `artifactType` filter was applied.
540+
541+
Example request with filtering:
542+
```
543+
GET /v2/<name>/referrers/<ref>?artifactType=application/vnd.example.icecream.v1
544+
```
545+
Response:
546+
```jsonc
547+
{
548+
"schemaVersion": 2,
549+
"mediaType": "application/vnd.oci.image.index.v1+json",
550+
"manifests": [
551+
{
552+
"mediaType": "application/vnd.oci.image.artifact.v1+json",
553+
"artifactType": "application/vnd.example.icecream.v1", // pulled up from manifest
554+
"size": 1234,
555+
"digest": "sha256:a1a1a1...",
556+
"annotations": [
557+
// annotations pulled up from manifest
558+
"org.opencontainers.artifact.created": "2022-01-01T14:42:55Z",
559+
"org.example.icecream.flavor": "chocolate"
560+
]
561+
}
562+
],
563+
"annotations": {
564+
"org.opencontainers.references.filtersApplied": "artifactType"
565+
}
566+
}
567+
```
568+
569+
538570
#### Content Management
539571

540572
Content management refers to the deletion of blobs, tags, and manifests.
@@ -579,22 +611,23 @@ This endpoint MAY be used for authentication/authorization purposes, but this is
579611

580612
#### Endpoints
581613

582-
| ID | Method | API Endpoint | Success | Failure |
583-
| ------ | -------------- | ------------------------------------------------------------ | ----------- | ----------------- |
584-
| end-1 | `GET` | `/v2/` | `200` | `404`/`401` |
585-
| end-2 | `GET` / `HEAD` | `/v2/<name>/blobs/<digest>` | `200` | `404` |
586-
| end-3 | `GET` / `HEAD` | `/v2/<name>/manifests/<reference>` | `200` | `404` |
587-
| end-4a | `POST` | `/v2/<name>/blobs/uploads/` | `202` | `404` |
588-
| end-4b | `POST` | `/v2/<name>/blobs/uploads/?digest=<digest>` | `201`/`202` | `404`/`400` |
589-
| end-5 | `PATCH` | `/v2/<name>/blobs/uploads/<reference>` | `202` | `404`/`416` |
590-
| end-6 | `PUT` | `/v2/<name>/blobs/uploads/<reference>?digest=<digest>` | `201` | `404`/`400` |
591-
| end-7 | `PUT` | `/v2/<name>/manifests/<reference>` | `201` | `404` |
592-
| end-8a | `GET` | `/v2/<name>/tags/list` | `200` | `404` |
593-
| end-8b | `GET` | `/v2/<name>/tags/list?n=<integer>&last=<integer>` | `200` | `404` |
594-
| end-9 | `DELETE` | `/v2/<name>/manifests/<reference>` | `202` | `404`/`400`/`405` |
595-
| end-10 | `DELETE` | `/v2/<name>/blobs/<digest>` | `202` | `404`/`405` |
596-
| end-11 | `POST` | `/v2/<name>/blobs/uploads/?mount=<digest>&from=<other_name>` | `201` | `404` |
597-
| end-12 | `GET` | `/v2/<name>/referrers/<reference>` | `200` | `404` |
614+
| ID | Method | API Endpoint | Success | Failure |
615+
| ------- | -------------- | -------------------------------------------------------------- | ----------- | ----------------- |
616+
| end-1 | `GET` | `/v2/` | `200` | `404`/`401` |
617+
| end-2 | `GET` / `HEAD` | `/v2/<name>/blobs/<digest>` | `200` | `404` |
618+
| end-3 | `GET` / `HEAD` | `/v2/<name>/manifests/<reference>` | `200` | `404` |
619+
| end-4a | `POST` | `/v2/<name>/blobs/uploads/` | `202` | `404` |
620+
| end-4b | `POST` | `/v2/<name>/blobs/uploads/?digest=<digest>` | `201`/`202` | `404`/`400` |
621+
| end-5 | `PATCH` | `/v2/<name>/blobs/uploads/<reference>` | `202` | `404`/`416` |
622+
| end-6 | `PUT` | `/v2/<name>/blobs/uploads/<reference>?digest=<digest>` | `201` | `404`/`400` |
623+
| end-7 | `PUT` | `/v2/<name>/manifests/<reference>` | `201` | `404` |
624+
| end-8a | `GET` | `/v2/<name>/tags/list` | `200` | `404` |
625+
| end-8b | `GET` | `/v2/<name>/tags/list?n=<integer>&last=<integer>` | `200` | `404` |
626+
| end-9 | `DELETE` | `/v2/<name>/manifests/<reference>` | `202` | `404`/`400`/`405` |
627+
| end-10 | `DELETE` | `/v2/<name>/blobs/<digest>` | `202` | `404`/`405` |
628+
| end-11 | `POST` | `/v2/<name>/blobs/uploads/?mount=<digest>&from=<other_name>` | `201` | `404` |
629+
| end-12a | `GET` | `/v2/<name>/referrers/<reference>` | `200` | `404` |
630+
| end-12b | `GET` | `/v2/<name>/referrers/<reference>?artifactType=<artifactType>` | `200` | `404` |
598631

599632
#### Error Codes
600633

upgrading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes how registries should add support for new APIs and featu
44

55
## Referrers API
66

7-
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12](spec.md#endpoints).
7+
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12a](spec.md#endpoints).
88
When registries add support for the Referrers API, this API needs to account for manifests that were pushed before the API was available using the [Client Implementation's tag schema](client-implementation.md#referrers-api).
99

1010
1. Registries MUST include preexisting Image and Artifact manifests that are listed in an Index tagged with the tag schema and have a valid Refers field.

0 commit comments

Comments
 (0)