Skip to content

Commit

Permalink
add the new option remote.WithJobs to default the operator according …
Browse files Browse the repository at this point in the history
…to CPU quota
  • Loading branch information
SubhasmitaSw committed Jun 14, 2022
1 parent 8f8efa4 commit 2eaee63
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -1174,7 +1173,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down
8 changes: 5 additions & 3 deletions pkg/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package builder
import (
"archive/tar"
"fmt"
"github.com/google/go-containerregistry/pkg/logs"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"io"
"io/fs"
"io/ioutil"
Expand All @@ -15,6 +12,10 @@ import (
"path/filepath"
"strings"

"github.com/google/go-containerregistry/pkg/logs"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/tarball"

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -52,6 +53,7 @@ func Build(options Options, dirs ...string) (string, error) {
}

StepLogger.Printf("Pushing image %s (insecure=%v)...", options.Target, options.PushInsecure)

if err := Push(newImage, options); err != nil {
return "", err
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/builder/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

Expand All @@ -31,7 +31,8 @@ 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...)
}

Expand All @@ -42,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))
Expand Down
1 change: 1 addition & 0 deletions pkg/builder/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ type Options struct {
Stdout io.Writer
Stderr io.Writer
Recursive bool
jobs int
}

0 comments on commit 2eaee63

Please sign in to comment.