0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00

use zot as an extension name, ext as a component and search as a module

add endpoints field in ext discover api

distribution spec extension discover api has endpoints field required.

https://github.com/opencontainers/distribution-spec/blob/main/extensions/_oci.md#extensions-property-descriptions

Signed-off-by: Shivam Mishra <shimish2@cisco.com>
This commit is contained in:
Shivam Mishra 2022-05-23 19:22:52 +00:00 committed by Ramkumar Chinchani
parent 5e22acbbc4
commit dcdeb935fd
5 changed files with 28 additions and 17 deletions

View file

@ -5,5 +5,5 @@ const (
ExtCatalogPrefix = "/_catalog"
ExtOciDiscoverPrefix = "/_oci/ext/discover"
// zot specific extensions.
ExtSearchPrefix = RoutePrefix + "/_search"
ExtSearchPrefix = RoutePrefix + "/_zot/ext/search"
)

View file

@ -4854,6 +4854,11 @@ func TestDistSpecExtensions(t *testing.T) {
err = json.Unmarshal(resp.Body(), &extensionList)
So(err, ShouldBeNil)
So(len(extensionList.Extensions), ShouldEqual, 1)
So(len(extensionList.Extensions[0].Endpoints), ShouldEqual, 1)
So(extensionList.Extensions[0].Name, ShouldEqual, "zot")
So(extensionList.Extensions[0].URL, ShouldContainSubstring, "_zot.md")
So(extensionList.Extensions[0].Description, ShouldNotBeEmpty)
So(extensionList.Extensions[0].Endpoints[0], ShouldEqual, constants.RoutePrefix+constants.ExtSearchPrefix)
})
Convey("start minimal zot server", t, func(c C) {

12
pkg/extensions/_zot.md Normal file
View file

@ -0,0 +1,12 @@
`zot` [extension](#references)
===
`zot` extension has following components accessible under `/v2/_zot` endpoint.
Component | Endpoint | Description
--- | --- | ---
[`search`](search/search.md) | `/v2/_zot/ext/search` | efficient and enhanced registry search capabilities using graphQL backend
# References
[1] https://github.com/opencontainers/distribution-spec/tree/main/extensions

View file

@ -112,11 +112,12 @@ func EnableScrubExtension(config *config.Config, storeController storage.StoreCo
}
}
func getExtension(name, url, description string) distext.Extension {
func getExtension(name, url, description string, endpoints []string) distext.Extension {
return distext.Extension{
Name: name,
URL: url,
Description: description,
Endpoints: endpoints,
}
}
@ -126,9 +127,10 @@ func GetExtensions(config *config.Config) distext.ExtensionList {
extensions := make([]distext.Extension, 0)
if config.Extensions != nil && config.Extensions.Search != nil {
searchExt := getExtension("search",
"https://github.com/project-zot/zot/tree/main/pkg/extensions/search/_search.md",
"search extension to provide various search feature e.g cve")
endpoints := []string{fmt.Sprintf("%s%s", constants.RoutePrefix, constants.ExtSearchPrefix)}
searchExt := getExtension("zot",
"https://github.com/project-zot/zot/tree/main/pkg/extensions/_zot.md",
"zot extension provide various components e.g search that provides various search capabilities", endpoints)
extensions = append(extensions, searchExt)
}

View file

@ -1,11 +1,6 @@
`search` extension
===
# `search`
`search` extension provides efficient and enhanced registry search capabilities using graphQL backend.
Table of Contents
===
`search` component provides efficient and enhanced registry search capabilities using graphQL backend.
| Supported queries | Input | Ouput | Description | graphQL query |
| --- | --- | --- | --- | --- |
@ -189,6 +184,3 @@ curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ ExpandedR
}
}
```
# References
[1] https://github.com/opencontainers/distribution-spec/tree/main/extensions