mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
refactor(cli): added equivalent subcommands for each flag combination under every command (#1674)
- image command is now deprecated in favor of 'images' - cve command is now deprecated in favor of 'cves' Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
+5
-1
@@ -111,7 +111,7 @@ func GetRepoReference(repo string) (string, string, bool, error) {
|
||||
return repoName, digest, false, nil
|
||||
}
|
||||
|
||||
// GetFullImageName returns the formated string for the given repo/tag or repo/digest.
|
||||
// GetFullImageName returns the formatted string for the given repo/tag or repo/digest.
|
||||
func GetFullImageName(repo, ref string) string {
|
||||
if IsTag(ref) {
|
||||
return repo + ":" + ref
|
||||
@@ -129,3 +129,7 @@ func IsDigest(ref string) bool {
|
||||
func IsTag(ref string) bool {
|
||||
return !IsDigest(ref)
|
||||
}
|
||||
|
||||
func CheckIsCorrectRepoNameFormat(repo string) bool {
|
||||
return !strings.ContainsAny(repo, ":@")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
func RetryWithContext(ctx context.Context, operation func(attempt int, retryIn time.Duration) error, maxRetries int,
|
||||
delay time.Duration,
|
||||
) error {
|
||||
err := operation(1, delay)
|
||||
|
||||
for attempt := 1; err != nil && attempt < maxRetries; attempt++ {
|
||||
select {
|
||||
case <-time.After(delay):
|
||||
case <-ctx.Done():
|
||||
return err
|
||||
}
|
||||
|
||||
err = operation(attempt+1, delay)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user