|
| 1 | +--- |
| 2 | +tags: oci,distribution |
| 3 | +breaks: false |
| 4 | +--- |
| 5 | + |
| 6 | +# Extensions API for Distribution |
| 7 | + |
| 8 | +Extensions, in general, to the distribution-spec API are allowed by the distribution-spec, with certain reservations disclosed herein. |
| 9 | +This document outlines a path for registry implementations and clients to iterate on new APIs, establish them, and propose them to OCI for canonical reference. |
| 10 | + |
| 11 | +The basis of the Extension API (`_oci`) should be emulated for all extensions. |
| 12 | + |
| 13 | +## Table |
| 14 | + |
| 15 | +_notice_: All new `/extensions/_<extention>.md` docs MUST be added to this table. |
| 16 | + |
| 17 | +| Extension | Summary | |
| 18 | +|:------------------------:|:----------------------------------------------------:| |
| 19 | +| [`_oci`](./_oci.md) | Extensions discovering extensions on registry server | |
| 20 | +| `_catalog` | Reserved prior extension | |
| 21 | + |
| 22 | +## Name |
| 23 | + |
| 24 | +Extension names MUST be unique. |
| 25 | +Extensions recorded in this distribution-spec are considered canonical definitions. |
| 26 | + |
| 27 | +Extensions are specified by extension name (`<extension>`) aligning with the project, followed by the `<component>`, and last by by the `<module>`. |
| 28 | +This constitutes the URI segments of the extension endpoint. |
| 29 | +Additional options may be passed as parameters to the endpoint. |
| 30 | + |
| 31 | +```http |
| 32 | +_<extension>/<component>/<module>[?<key>=<value>&...] |
| 33 | +``` |
| 34 | + |
| 35 | +The values of `<extension>`, `<component>`, and `<module>` MUST conform to the following regular expression: |
| 36 | + |
| 37 | +`[a-z0-9]+([._-][a-z0-9]+)` |
| 38 | + |
| 39 | +Note: the leading `_` on the extension is a prefix before this regular expression. |
| 40 | + |
| 41 | +### Registry-Level Extensions |
| 42 | + |
| 43 | +Registry-level extensions are nested under `/v2`. |
| 44 | + |
| 45 | +```http |
| 46 | +GET /v2/_<extension>/<component>/<module>[?<key>=<value>&...] |
| 47 | +``` |
| 48 | + |
| 49 | +A contrived example of a search extension may be of the form `/v2/_oci/catalog/search?pattern=foo?n=10` |
| 50 | + |
| 51 | +### Repository-Level Extensions |
| 52 | + |
| 53 | +Repository-level extension endpoints are scoped under a repository name. |
| 54 | + |
| 55 | +Repository-level extensions follow the same naming rules as the [registry-level endpoints](#registry-level-extensions). |
| 56 | + |
| 57 | +```http |
| 58 | +GET /v2/<name>/_<extension>/<component>/<module>[?<key>=<value>&...] |
| 59 | +``` |
| 60 | + |
| 61 | +### Reserved Namespaces |
| 62 | + |
| 63 | +As of current, `_oci` and `_catalog` are considered as reserved namespaces and cannot be used by other extensions. |
| 64 | + |
| 65 | +### Versioning |
| 66 | + |
| 67 | +Data payloads being exchanged from extensions SHOULD handle versioned data structures this with `Accepts` and `Content-type` HTTP headers (LINK TO RFC). |
| 68 | + |
| 69 | +If an extension has fundamentally changed enough, then it SHOULD be introduced as a new `<component>` and/or `<component>/<module>`. |
| 70 | +Whether or not there is versioning built into those names is up to the extension maintainer. |
| 71 | + |
| 72 | +## Filename |
| 73 | + |
| 74 | +Extension definitions SHOULD be placed under `./extensions/` in the specification repository. |
| 75 | +Extension files SHOULD follow the `_<extension>.md` pattern. |
| 76 | +Refer [_oci.md](./_oci.md) for more details. |
| 77 | + |
| 78 | +## Detail |
| 79 | + |
| 80 | +Extensions details MAY describe more endpoints and APIs that it MAY support. |
| 81 | +It is also recommended to call out error codes encountered and enumerated as in the |
| 82 | +in the following table: |
| 83 | + |
| 84 | +| Code | Message | Description | |
| 85 | +|---------------------|----------------------|-----------------------------------------------------| |
| 86 | +| `EXTENSION_UNKNOWN` | Extension is unknown | This error MAY be returned when a extension is unknown to the registry in a specified repository. This can be returned with a standard get or if a manifest references an unknown layer during upload. | |
| 87 | + |
| 88 | +## Pagination |
| 89 | + |
| 90 | +Extensions implementing pagination and SHOULD align with the [pagination](./spec.md#pagination) specification. |
| 91 | + |
| 92 | +Extension MAY provide enumeration without lexical ordering and in this case, it is not required to support the `last` parameter. |
| 93 | +Clients are NOT RECOMMENDED to construct the `link` and SHOULD treat the URL as opaque. |
| 94 | + |
| 95 | +## Prior Art |
| 96 | + |
| 97 | +When considering the proposal structure for these extensions, the following processes were considered: |
| 98 | + |
| 99 | +* [Python PEP](https://www.python.org/dev/peps/) |
| 100 | +* [Kubernetes KEP](https://github.com/kubernetes/enhancements/tree/master/keps) |
0 commit comments