Stop using deprecated names from c/common/pkg/retry

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2022-07-25 18:15:53 +02:00
parent 08846d18cc
commit b7e7374e71
7 changed files with 22 additions and 22 deletions

View File

@@ -25,7 +25,7 @@ type copyOptions struct {
deprecatedTLSVerify *deprecatedTLSVerifyOption deprecatedTLSVerify *deprecatedTLSVerifyOption
srcImage *imageOptions srcImage *imageOptions
destImage *imageDestOptions destImage *imageDestOptions
retryOpts *retry.RetryOptions retryOpts *retry.Options
additionalTags []string // For docker-archive: destinations, in addition to the name:tag specified as destination, also add these additionalTags []string // For docker-archive: destinations, in addition to the name:tag specified as destination, also add these
removeSignatures bool // Do not copy signatures from the source image removeSignatures bool // Do not copy signatures from the source image
signByFingerprint string // Sign the image using a GPG key with the specified fingerprint signByFingerprint string // Sign the image using a GPG key with the specified fingerprint
@@ -260,7 +260,7 @@ func (opts *copyOptions) run(args []string, stdout io.Writer) (retErr error) {
} }
} }
return retry.RetryIfNecessary(ctx, func() error { return retry.IfNecessary(ctx, func() error {
manifestBytes, err := copy.Image(ctx, policyContext, destRef, srcRef, &copy.Options{ manifestBytes, err := copy.Image(ctx, policyContext, destRef, srcRef, &copy.Options{
RemoveSignatures: opts.removeSignatures, RemoveSignatures: opts.removeSignatures,
SignBy: opts.signByFingerprint, SignBy: opts.signByFingerprint,

View File

@@ -15,7 +15,7 @@ import (
type deleteOptions struct { type deleteOptions struct {
global *globalOptions global *globalOptions
image *imageOptions image *imageOptions
retryOpts *retry.RetryOptions retryOpts *retry.Options
} }
func deleteCmd(global *globalOptions) *cobra.Command { func deleteCmd(global *globalOptions) *cobra.Command {
@@ -70,7 +70,7 @@ func (opts *deleteOptions) run(args []string, stdout io.Writer) error {
ctx, cancel := opts.global.commandTimeoutContext() ctx, cancel := opts.global.commandTimeoutContext()
defer cancel() defer cancel()
return retry.RetryIfNecessary(ctx, func() error { return retry.IfNecessary(ctx, func() error {
return ref.DeleteImage(ctx, sys) return ref.DeleteImage(ctx, sys)
}, opts.retryOpts) }, opts.retryOpts)
} }

View File

@@ -26,7 +26,7 @@ import (
type inspectOptions struct { type inspectOptions struct {
global *globalOptions global *globalOptions
image *imageOptions image *imageOptions
retryOpts *retry.RetryOptions retryOpts *retry.Options
format string format string
raw bool // Output the raw manifest instead of parsing information about the image raw bool // Output the raw manifest instead of parsing information about the image
config bool // Output the raw config blob instead of parsing information about the image config bool // Output the raw config blob instead of parsing information about the image
@@ -96,7 +96,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
return err return err
} }
if err := retry.RetryIfNecessary(ctx, func() error { if err := retry.IfNecessary(ctx, func() error {
src, err = parseImageSource(ctx, opts.image, imageName) src, err = parseImageSource(ctx, opts.image, imageName)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -109,7 +109,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
} }
}() }()
if err := retry.RetryIfNecessary(ctx, func() error { if err := retry.IfNecessary(ctx, func() error {
rawManifest, _, err = src.GetManifest(ctx, nil) rawManifest, _, err = src.GetManifest(ctx, nil)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -132,7 +132,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
if opts.config && opts.raw { if opts.config && opts.raw {
var configBlob []byte var configBlob []byte
if err := retry.RetryIfNecessary(ctx, func() error { if err := retry.IfNecessary(ctx, func() error {
configBlob, err = img.ConfigBlob(ctx) configBlob, err = img.ConfigBlob(ctx)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -145,7 +145,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
return nil return nil
} else if opts.config { } else if opts.config {
var config *v1.Image var config *v1.Image
if err := retry.RetryIfNecessary(ctx, func() error { if err := retry.IfNecessary(ctx, func() error {
config, err = img.OCIConfig(ctx) config, err = img.OCIConfig(ctx)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -168,7 +168,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
return nil return nil
} }
if err := retry.RetryIfNecessary(ctx, func() error { if err := retry.IfNecessary(ctx, func() error {
imgInspect, err = img.Inspect(ctx) imgInspect, err = img.Inspect(ctx)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {

View File

@@ -19,7 +19,7 @@ import (
type layersOptions struct { type layersOptions struct {
global *globalOptions global *globalOptions
image *imageOptions image *imageOptions
retryOpts *retry.RetryOptions retryOpts *retry.Options
} }
func layersCmd(global *globalOptions) *cobra.Command { func layersCmd(global *globalOptions) *cobra.Command {
@@ -68,13 +68,13 @@ func (opts *layersOptions) run(args []string, stdout io.Writer) (retErr error) {
rawSource types.ImageSource rawSource types.ImageSource
src types.ImageCloser src types.ImageCloser
) )
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
rawSource, err = parseImageSource(ctx, opts.image, imageName) rawSource, err = parseImageSource(ctx, opts.image, imageName)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
return err return err
} }
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
src, err = image.FromSource(ctx, sys, rawSource) src, err = image.FromSource(ctx, sys, rawSource)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -145,7 +145,7 @@ func (opts *layersOptions) run(args []string, stdout io.Writer) (retErr error) {
r io.ReadCloser r io.ReadCloser
blobSize int64 blobSize int64
) )
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
r, blobSize, err = rawSource.GetBlob(ctx, types.BlobInfo{Digest: bd.digest, Size: -1}, cache) r, blobSize, err = rawSource.GetBlob(ctx, types.BlobInfo{Digest: bd.digest, Size: -1}, cache)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -160,7 +160,7 @@ func (opts *layersOptions) run(args []string, stdout io.Writer) (retErr error) {
} }
var manifest []byte var manifest []byte
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
manifest, _, err = src.Manifest(ctx) manifest, _, err = src.Manifest(ctx)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {

View File

@@ -27,7 +27,7 @@ type tagListOutput struct {
type tagsOptions struct { type tagsOptions struct {
global *globalOptions global *globalOptions
image *imageOptions image *imageOptions
retryOpts *retry.RetryOptions retryOpts *retry.Options
} }
var transportHandlers = map[string]func(ctx context.Context, sys *types.SystemContext, opts *tagsOptions, userInput string) (repositoryName string, tagListing []string, err error){ var transportHandlers = map[string]func(ctx context.Context, sys *types.SystemContext, opts *tagsOptions, userInput string) (repositoryName string, tagListing []string, err error){
@@ -120,7 +120,7 @@ func listDockerRepoTags(ctx context.Context, sys *types.SystemContext, opts *tag
if err != nil { if err != nil {
return return
} }
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
repositoryName, tagListing, err = listDockerTags(ctx, sys, imgRef) repositoryName, tagListing, err = listDockerTags(ctx, sys, imgRef)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {

View File

@@ -33,7 +33,7 @@ type syncOptions struct {
deprecatedTLSVerify *deprecatedTLSVerifyOption deprecatedTLSVerify *deprecatedTLSVerifyOption
srcImage *imageOptions // Source image options srcImage *imageOptions // Source image options
destImage *imageDestOptions // Destination image options destImage *imageDestOptions // Destination image options
retryOpts *retry.RetryOptions retryOpts *retry.Options
removeSignatures bool // Do not copy signatures from the source image removeSignatures bool // Do not copy signatures from the source image
signByFingerprint string // Sign the image using a GPG key with the specified fingerprint signByFingerprint string // Sign the image using a GPG key with the specified fingerprint
signBySigstorePrivateKey string // Sign the image using a sigstore private key signBySigstorePrivateKey string // Sign the image using a sigstore private key
@@ -571,7 +571,7 @@ func (opts *syncOptions) run(args []string, stdout io.Writer) (retErr error) {
sourceArg := args[0] sourceArg := args[0]
var srcRepoList []repoDescriptor var srcRepoList []repoDescriptor
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
srcRepoList, err = imagesToCopy(sourceArg, opts.source, sourceCtx) srcRepoList, err = imagesToCopy(sourceArg, opts.source, sourceCtx)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {
@@ -657,7 +657,7 @@ func (opts *syncOptions) run(args []string, stdout io.Writer) (retErr error) {
logrus.WithFields(fromToFields).Infof("Would have copied image ref %d/%d", counter+1, len(srcRepo.ImageRefs)) logrus.WithFields(fromToFields).Infof("Would have copied image ref %d/%d", counter+1, len(srcRepo.ImageRefs))
} else { } else {
logrus.WithFields(fromToFields).Infof("Copying image ref %d/%d", counter+1, len(srcRepo.ImageRefs)) logrus.WithFields(fromToFields).Infof("Copying image ref %d/%d", counter+1, len(srcRepo.ImageRefs))
if err = retry.RetryIfNecessary(ctx, func() error { if err = retry.IfNecessary(ctx, func() error {
_, err = copy.Image(ctx, policyContext, destRef, ref, &options) _, err = copy.Image(ctx, policyContext, destRef, ref, &options)
return err return err
}, opts.retryOpts); err != nil { }, opts.retryOpts); err != nil {

View File

@@ -174,8 +174,8 @@ func imageFlags(global *globalOptions, shared *sharedImageOptions, deprecatedTLS
return fs, opts return fs, opts
} }
func retryFlags() (pflag.FlagSet, *retry.RetryOptions) { func retryFlags() (pflag.FlagSet, *retry.Options) {
opts := retry.RetryOptions{} opts := retry.Options{}
fs := pflag.FlagSet{} fs := pflag.FlagSet{}
fs.IntVar(&opts.MaxRetry, "retry-times", 0, "the number of times to possibly retry") fs.IntVar(&opts.MaxRetry, "retry-times", 0, "the number of times to possibly retry")
return fs, &opts return fs, &opts