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:
LaurentiuNiculae
2023-08-30 20:12:24 +03:00
committed by GitHub
parent 2bd479edd7
commit 112fbec5b6
49 changed files with 3857 additions and 315 deletions
+5 -1
View File
@@ -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, ":@")
}
+24
View File
@@ -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
}