-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(userprefs): update documentation and list extensions endpoint
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
- Loading branch information
1 parent
2be5459
commit a9d16eb
Showing
5 changed files
with
85 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package extensions | ||
|
||
import ( | ||
distext "github.com/opencontainers/distribution-spec/specs-go/v1/extensions" | ||
|
||
"zotregistry.io/zot/pkg/api/config" | ||
"zotregistry.io/zot/pkg/api/constants" | ||
) | ||
|
||
func GetExtensions(config *config.Config) distext.ExtensionList { | ||
extensionList := distext.ExtensionList{} | ||
|
||
extensions := make([]distext.Extension, 0) | ||
|
||
if config.Extensions != nil && config.Extensions.Search != nil { | ||
endpoints := []string{constants.FullSearchPrefix} | ||
searchExt := distext.Extension{ | ||
Name: "_zot", | ||
URL: "https://github.com/project-zot/zot/blob/" + config.ReleaseTag + "/pkg/extensions/_zot.md", | ||
Description: "zot registry extensions", | ||
Endpoints: endpoints, | ||
} | ||
|
||
extensions = append(extensions, searchExt) | ||
|
||
endpoints = []string{constants.FullUserPreferencesPrefix} | ||
|
||
userPrefsExt := distext.Extension{ | ||
Name: "_zot", | ||
URL: "https://github.com/project-zot/zot/blob/" + config.ReleaseTag + "/pkg/extensions/_zot.md", | ||
Description: "zot registry extensions", | ||
Endpoints: endpoints, | ||
} | ||
|
||
extensions = append(extensions, userPrefsExt) | ||
} | ||
|
||
if config.Extensions != nil && config.Extensions.Mgmt != nil { | ||
endpoints := []string{constants.FullMgmtPrefix} | ||
mgmtExt := distext.Extension{ | ||
Name: "_zot", | ||
URL: "https://github.com/project-zot/zot/blob/" + config.ReleaseTag + "/pkg/extensions/_zot.md", | ||
Description: "zot registry extensions", | ||
Endpoints: endpoints, | ||
} | ||
|
||
extensions = append(extensions, mgmtExt) | ||
} | ||
|
||
extensionList.Extensions = extensions | ||
|
||
return extensionList | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# `userprefs` | ||
|
||
`userprefs` component provides an endpoint for adding user preferences for repos. It is available only to authentificated users. Unauthentificated users will be denied access. | ||
|
||
| Supported queries | Input | Output | Description | | ||
| --- | --- | --- | --- | | ||
| [Toggle repo star](#toggle-repo-star) | None | None | Sets the repo starred property to true if it is false, and to false if it is true | | ||
| [Toggle repo bookmark](#toggle-repo-bookmark) | None | None | Sets the repo bookmarked property to true if it is false, and to false if it is true | | ||
|
||
## General usage | ||
The userprefs endpoint accepts as a query parameter what `action` to perform and then all other required parameters for the specified action. | ||
|
||
## Toggle repo star | ||
| Action | Parameter | Parameter Type | Parameter Description | | ||
| --- | --- | --- | --- | | ||
| toggleStar | repo | string | The repo name which should be starred | | ||
|
||
A request to togle a star on a repo would look like this: | ||
``` | ||
(PUT) http://localhost:8080/v2/_zot/ext/userprefs?action=toggleStar&repo=repoName | ||
``` | ||
|
||
## Toggle repo bookmark | ||
| Action | Parameter | Parameter Type | Parameter Description | | ||
| --- | --- | --- | --- | | ||
| toggleBookmark | repo | string | The repo name which should be bookmarked | | ||
|
||
A request to togle a bookmark on a repo would look like this: | ||
``` | ||
(PUT) http://localhost:8080/v2/_zot/ext/userprefs?action=toggleBookmark&repo=repoName | ||
``` |