mirror of
https://github.com/containers/skopeo.git
synced 2025-09-04 16:20:23 +00:00
Update module github.com/containers/common to v0.54.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
20
vendor/github.com/containers/common/pkg/completion/completion.go
generated
vendored
20
vendor/github.com/containers/common/pkg/completion/completion.go
generated
vendored
@@ -23,19 +23,19 @@ func CompleteCommandFlags(cmd *cobra.Command, flags FlagCompletions) {
|
||||
/* Autocomplete Functions for cobra ValidArgsFunction */
|
||||
|
||||
// AutocompleteNone - Block the default shell completion (no paths)
|
||||
func AutocompleteNone(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteNone(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
// AutocompleteDefault - Use the default shell completion,
|
||||
// allows path completion.
|
||||
func AutocompleteDefault(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteDefault(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
// AutocompleteCapabilities - Autocomplete linux capabilities options.
|
||||
// Used by --cap-add and --cap-drop.
|
||||
func AutocompleteCapabilities(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteCapabilities(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
caps := capabilities.AllCapabilities()
|
||||
|
||||
// convertCase will convert a string to lowercase only if the user input is lowercase
|
||||
@@ -83,17 +83,17 @@ func autocompleteSubIDName(filename string) ([]string, cobra.ShellCompDirective)
|
||||
}
|
||||
|
||||
// AutocompleteSubgidName - Autocomplete subgidname based on the names in the /etc/subgid file.
|
||||
func AutocompleteSubgidName(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteSubgidName(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return autocompleteSubIDName("/etc/subgid")
|
||||
}
|
||||
|
||||
// AutocompleteSubuidName - Autocomplete subuidname based on the names in the /etc/subuid file.
|
||||
func AutocompleteSubuidName(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteSubuidName(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return autocompleteSubIDName("/etc/subuid")
|
||||
}
|
||||
|
||||
// AutocompleteArch - Autocomplete platform supported by container engines
|
||||
func AutocompletePlatform(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompletePlatform(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
completions := []string{
|
||||
"linux/386",
|
||||
"linux/amd64",
|
||||
@@ -115,7 +115,7 @@ func AutocompletePlatform(cmd *cobra.Command, args []string, toComplete string)
|
||||
}
|
||||
|
||||
// AutocompleteArch - Autocomplete architectures supported by container engines
|
||||
func AutocompleteArch(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteArch(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
completions := []string{
|
||||
"386",
|
||||
"amd64",
|
||||
@@ -135,19 +135,19 @@ func AutocompleteArch(cmd *cobra.Command, args []string, toComplete string) ([]s
|
||||
}
|
||||
|
||||
// AutocompleteOS - Autocomplete OS supported by container engines
|
||||
func AutocompleteOS(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteOS(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
completions := []string{"linux", "windows"}
|
||||
return completions, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
// AutocompleteJSONFormat - Autocomplete format flag option.
|
||||
// -> "json"
|
||||
func AutocompleteJSONFormat(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteJSONFormat(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
return []string{"json"}, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
// AutocompleteOneArg - Autocomplete one random arg
|
||||
func AutocompleteOneArg(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
func AutocompleteOneArg(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) == 1 {
|
||||
return nil, cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
29
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
29
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
@@ -17,8 +17,9 @@ import (
|
||||
|
||||
// Options defines the option to retry.
|
||||
type Options struct {
|
||||
MaxRetry int // The number of times to possibly retry.
|
||||
Delay time.Duration // The delay to use between retries, if set.
|
||||
MaxRetry int // The number of times to possibly retry.
|
||||
Delay time.Duration // The delay to use between retries, if set.
|
||||
IsErrorRetryable func(error) bool
|
||||
}
|
||||
|
||||
// RetryOptions is deprecated, use Options.
|
||||
@@ -31,6 +32,12 @@ func RetryIfNecessary(ctx context.Context, operation func() error, options *Opti
|
||||
|
||||
// IfNecessary retries the operation in exponential backoff with the retry Options.
|
||||
func IfNecessary(ctx context.Context, operation func() error, options *Options) error {
|
||||
var isRetryable func(error) bool
|
||||
if options.IsErrorRetryable != nil {
|
||||
isRetryable = options.IsErrorRetryable
|
||||
} else {
|
||||
isRetryable = IsErrorRetryable
|
||||
}
|
||||
err := operation()
|
||||
for attempt := 0; err != nil && isRetryable(err) && attempt < options.MaxRetry; attempt++ {
|
||||
delay := time.Duration(int(math.Pow(2, float64(attempt)))) * time.Second
|
||||
@@ -49,7 +56,11 @@ func IfNecessary(ctx context.Context, operation func() error, options *Options)
|
||||
return err
|
||||
}
|
||||
|
||||
func isRetryable(err error) bool {
|
||||
// IsErrorRetryable makes a HEURISTIC determination whether it is worth retrying upon encountering an error.
|
||||
// That heuristic is NOT STABLE and it CAN CHANGE AT ANY TIME.
|
||||
// Callers that have a hard requirement for specific treatment of a class of errors should make their own check
|
||||
// instead of relying on this function maintaining its past behavior.
|
||||
func IsErrorRetryable(err error) bool {
|
||||
switch err {
|
||||
case nil:
|
||||
return false
|
||||
@@ -72,18 +83,18 @@ func isRetryable(err error) bool {
|
||||
}
|
||||
return true
|
||||
case *net.OpError:
|
||||
return isRetryable(e.Err)
|
||||
return IsErrorRetryable(e.Err)
|
||||
case *url.Error: // This includes errors returned by the net/http client.
|
||||
if e.Err == io.EOF { // Happens when a server accepts a HTTP connection and sends EOF
|
||||
return true
|
||||
}
|
||||
return isRetryable(e.Err)
|
||||
return IsErrorRetryable(e.Err)
|
||||
case syscall.Errno:
|
||||
return isErrnoRetryable(e)
|
||||
case errcode.Errors:
|
||||
// if this error is a group of errors, process them all in turn
|
||||
for i := range e {
|
||||
if !isRetryable(e[i]) {
|
||||
if !IsErrorRetryable(e[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -91,7 +102,7 @@ func isRetryable(err error) bool {
|
||||
case *multierror.Error:
|
||||
// if this error is a group of errors, process them all in turn
|
||||
for i := range e.Errors {
|
||||
if !isRetryable(e.Errors[i]) {
|
||||
if !IsErrorRetryable(e.Errors[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -102,11 +113,11 @@ func isRetryable(err error) bool {
|
||||
}
|
||||
if unwrappable, ok := e.(unwrapper); ok {
|
||||
err = unwrappable.Unwrap()
|
||||
return isRetryable(err)
|
||||
return IsErrorRetryable(err)
|
||||
}
|
||||
case unwrapper: // Test this last, because various error types might implement .Unwrap()
|
||||
err = e.Unwrap()
|
||||
return isRetryable(err)
|
||||
return IsErrorRetryable(err)
|
||||
}
|
||||
|
||||
return false
|
||||
|
Reference in New Issue
Block a user