feat(cli): add referrers and search commands to cli (#1497)

* feat(cli): add referrers command to cli

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>

* feat(cli): add global search command

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>

* feat(cli): fix comments

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>

---------

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
LaurentiuNiculae
2023-06-22 20:43:01 +03:00
committed by GitHub
parent ea7dbf9e5c
commit 620287c7a4
16 changed files with 1993 additions and 81 deletions
+10 -9
View File
@@ -15,15 +15,16 @@ 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"`
IsStarred bool `json:"isStarred"`
IsBookmarked bool `json:"isBookmarked"`
StarCount int `json:"starCount"`
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"`
DownloadCount int `json:"downloadCount"`
NewestImage ImageSummary `json:"newestImage"`
}
type PaginatedImagesResult struct {
+29
View File
@@ -5,6 +5,8 @@ import (
"time"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
zerr "zotregistry.io/zot/errors"
)
func GetImageDirAndTag(imageName string) (string, string) {
@@ -76,3 +78,30 @@ func GetImageLastUpdated(imageInfo ispec.Image) time.Time {
return *timeStamp
}
// GetRepoRefference returns the components of a repoName:tag or repoName@digest string. If the format is wrong
// an error is returned.
// The returned values have the following meaning:
//
// - string: repo name
//
// - string: reference (tag or digest)
//
// - bool: value for the statement: "the reference is a tag"
//
// - error: error value.
func GetRepoRefference(repo string) (string, string, bool, error) {
repoName, digest, found := strings.Cut(repo, "@")
if !found {
repoName, tag, found := strings.Cut(repo, ":")
if !found {
return "", "", false, zerr.ErrInvalidRepoTagFormat
}
return repoName, tag, true, nil
}
return repoName, digest, false, nil
}