mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
feat(repodb): add user related information to repodb (#1317)
Initial code was contributed by Bogdan BIVOLARU <104334+bogdanbiv@users.noreply.github.com> Moved implementation from a separate db to repodb by Andrei Aaron <aaaron@luxoft.com> Not done yet: - run/test dynamodb implementation, only boltdb was tested - add additional coverage for existing functionality - add web-based APIs to toggle the stars/bookmarks on/off Initially graphql mutation was discussed for the missing API but we decided REST endpoints would be better suited for configuration feat(userdb): complete functionality for userdb integration - dynamodb rollback changes to user starred repos in case increasing the total star count fails - dynamodb increment/decrement repostars in repometa when user stars/unstars a repo - dynamodb check anonymous user permissions are working as intendend - common test handle anonymous users - RepoMeta2RepoSummary set IsStarred and IsBookmarked feat(userdb): rest api calls for toggling stars/bookmarks on/off test(userdb): blackbox tests test(userdb): move preferences tests in a different file with specific build tags feat(repodb): add is-starred and is-bookmarked fields to repo-meta - removed duplicated logic for determining if a repo is starred/bookmarked Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com> Co-authored-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -40,6 +40,30 @@ func Contains(slice []string, item string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// first match of item in [].
|
||||
func Index(slice []string, item string) int {
|
||||
for k, v := range slice {
|
||||
if item == v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
// remove matches of item in [].
|
||||
func RemoveFrom(inputSlice []string, item string) []string {
|
||||
var newSlice []string
|
||||
|
||||
for _, v := range inputSlice {
|
||||
if item != v {
|
||||
newSlice = append(newSlice, v)
|
||||
}
|
||||
}
|
||||
|
||||
return newSlice
|
||||
}
|
||||
|
||||
func GetTLSConfig(certsPath string, caCertPool *x509.CertPool) (*tls.Config, error) {
|
||||
clientCert := filepath.Join(certsPath, clientCertFilename)
|
||||
clientKey := filepath.Join(certsPath, clientKeyFilename)
|
||||
|
||||
@@ -119,6 +119,11 @@ func TestCommon(t *testing.T) {
|
||||
resultPtr, baseURL+"/v2/", ispec.MediaTypeImageManifest, log.NewLogger("", ""))
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("Index func", t, func() {
|
||||
So(common.Index([]string{"a", "b"}, "b"), ShouldEqual, 1)
|
||||
So(common.Index([]string{"a", "b"}, "c"), ShouldEqual, -1)
|
||||
})
|
||||
Convey("Test image dir and digest", t, func() {
|
||||
repo, digest := common.GetImageDirAndDigest("image")
|
||||
So(repo, ShouldResemble, "image")
|
||||
|
||||
+9
-6
@@ -10,12 +10,15 @@ type RepoInfo struct {
|
||||
}
|
||||
|
||||
type RepoSummary struct {
|
||||
Name string `json:"name"`
|
||||
LastUpdated time.Time `json:"lastUpdated"`
|
||||
Size string `json:"size"`
|
||||
Platforms []Platform `json:"platforms"`
|
||||
Vendors []string `json:"vendors"`
|
||||
NewestImage ImageSummary `json:"newestImage"`
|
||||
Name string `json:"name"`
|
||||
LastUpdated time.Time `json:"lastUpdated"`
|
||||
Size string `json:"size"`
|
||||
Platforms []Platform `json:"platforms"`
|
||||
Vendors []string `json:"vendors"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
IsBookmarked bool `json:"isBookmarked"`
|
||||
StarCount int `json:"starCount"`
|
||||
NewestImage ImageSummary `json:"newestImage"`
|
||||
}
|
||||
|
||||
type ImageSummary struct {
|
||||
|
||||
Reference in New Issue
Block a user