From 8621a6c5710461f64b38d0a5540bc8ad6da8726d Mon Sep 17 00:00:00 2001 From: Subhasmita Swain Date: Tue, 14 Jun 2022 22:26:32 +0530 Subject: [PATCH] update options.jobs in makeRemoteOptions --- pkg/builder/build.go | 6 ------ pkg/builder/image.go | 9 ++++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/builder/build.go b/pkg/builder/build.go index 2bd5fa0..decba28 100644 --- a/pkg/builder/build.go +++ b/pkg/builder/build.go @@ -14,7 +14,6 @@ import ( "github.com/google/go-containerregistry/pkg/logs" "github.com/google/go-containerregistry/pkg/v1/mutate" - "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/tarball" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -55,11 +54,6 @@ func Build(options Options, dirs ...string) (string, error) { StepLogger.Printf("Pushing image %s (insecure=%v)...", options.Target, options.PushInsecure) - remoteOptions := makeRemoteOptions(options.PullConfigDir) - if options.jobs > 0 { - remoteOptions = append(remoteOptions, remote.WithJobs(options.jobs)) - } - if err := Push(newImage, options); err != nil { return "", err } diff --git a/pkg/builder/image.go b/pkg/builder/image.go index b62d48e..10368b7 100644 --- a/pkg/builder/image.go +++ b/pkg/builder/image.go @@ -20,7 +20,7 @@ func Pull(options Options) (v1.Image, error) { return nil, fmt.Errorf("parsing tag %q: %v", options.Base, err) } - remoteOptions := makeRemoteOptions(options.PullConfigDir) + remoteOptions := makeRemoteOptions(options, options.PullConfigDir) return remote.Image(ref, remoteOptions...) } @@ -31,7 +31,7 @@ func Push(img v1.Image, options Options) error { return fmt.Errorf("parsing tag %q: %v", options.Target, err) } - remoteOptions := makeRemoteOptions(options.PushConfigDir) + remoteOptions := makeRemoteOptions(options, options.PushConfigDir) remoteOptions = append(remoteOptions, remote.WithJobs(options.jobs)) return remote.Write(tag, img, remoteOptions...) } @@ -43,7 +43,10 @@ func makeNameOptions(insecure bool) (nameOptions []name.Option) { return } -func makeRemoteOptions(configDir string) (remoteOptions []remote.Option) { +func makeRemoteOptions(options Options, configDir string) (remoteOptions []remote.Option) { + if options.jobs > 0 { + remoteOptions = append(remoteOptions, remote.WithJobs(options.jobs)) + } if configDir != "" { keyChain := NewDirKeyChain(configDir) remoteOptions = append(remoteOptions, remote.WithAuthFromKeychain(keyChain))