diff --git a/pkg/api/constants/extensions.go b/pkg/api/constants/extensions.go index d1fe7d58..6e3105ee 100644 --- a/pkg/api/constants/extensions.go +++ b/pkg/api/constants/extensions.go @@ -5,5 +5,5 @@ const ( ExtCatalogPrefix = "/_catalog" ExtOciDiscoverPrefix = "/_oci/ext/discover" // zot specific extensions. - ExtSearchPrefix = RoutePrefix + "/_search" + ExtSearchPrefix = RoutePrefix + "/_zot/ext/search" ) diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 0b692d99..87aac3f6 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -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) { diff --git a/pkg/extensions/_zot.md b/pkg/extensions/_zot.md new file mode 100644 index 00000000..1cf8d3f5 --- /dev/null +++ b/pkg/extensions/_zot.md @@ -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 diff --git a/pkg/extensions/extensions.go b/pkg/extensions/extensions.go index 630eb9f7..57978b35 100644 --- a/pkg/extensions/extensions.go +++ b/pkg/extensions/extensions.go @@ -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) } diff --git a/pkg/extensions/_search.md b/pkg/extensions/search/search.md similarity index 96% rename from pkg/extensions/_search.md rename to pkg/extensions/search/search.md index 5f5e9ae9..459ad3c5 100644 --- a/pkg/extensions/_search.md +++ b/pkg/extensions/search/search.md @@ -1,12 +1,7 @@ -`search` extension -=== - -`search` extension provides efficient and enhanced registry search capabilities using graphQL backend. - - -Table of Contents -=== +# `search` +`search` component provides efficient and enhanced registry search capabilities using graphQL backend. + | Supported queries | Input | Ouput | Description | graphQL query | | --- | --- | --- | --- | --- | | [Search images by digest](#search-images-by-digest) | digest | image list | Search all repositories in the registry and return list of images that matches given digest (manifest, config or layers) | ImageListForDigest | @@ -92,7 +87,7 @@ curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ CVEListFo }] } } - } + } ``` # List images not affected by a given CVE id @@ -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