mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
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:
+10
-9
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user