Skip to content

Commit 7d2a487

Browse files
authored
Merge pull request #1057 from jonjohnsonjr/plumb-jobs
build: Plumb --jobs to bundle builds
2 parents 5b1082b + 86e35e3 commit 7d2a487

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

pkg/cli/build.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ import (
6060
)
6161

6262
func cmdBuild() *cobra.Command {
63-
var jobs int
6463
var traceFile string
6564
var anns []string // string list annotations
6665

@@ -109,11 +108,11 @@ func cmdBuild() *cobra.Command {
109108
ctx = tctx
110109
}
111110

112-
if jobs == 0 {
113-
jobs = runtime.GOMAXPROCS(0)
111+
if cfg.Jobs == 0 {
112+
cfg.Jobs = runtime.GOMAXPROCS(0)
114113
}
115-
cfg.jobch = make(chan struct{}, jobs)
116-
cfg.donech = make(chan *task, jobs)
114+
cfg.jobch = make(chan struct{}, cfg.Jobs)
115+
cfg.donech = make(chan *task, cfg.Jobs)
117116

118117
if cfg.signingKey == "" {
119118
cfg.signingKey = filepath.Join(cfg.Dir, "local-melange.rsa")
@@ -165,7 +164,7 @@ func cmdBuild() *cobra.Command {
165164
cmd.Flags().StringVar(&cfg.Bundle, "bundle", "", "bundle of work to do (experimental)")
166165
cmd.Flags().StringVar(&cfg.StagingBucket, "bucket", "", "gcs bucket to upload results (experimental)")
167166

168-
cmd.Flags().IntVarP(&jobs, "jobs", "j", 0, "number of jobs to run concurrently (default is GOMAXPROCS)")
167+
cmd.Flags().IntVarP(&cfg.Jobs, "jobs", "j", 0, "number of jobs to run concurrently (default is GOMAXPROCS)")
169168
cmd.Flags().StringVar(&traceFile, "trace", "", "where to write trace output")
170169

171170
cmd.Flags().StringVar(&cfg.K8sNamespace, "k8s-namespace", "default", "namespace to deploy pods into for builds.")
@@ -357,9 +356,11 @@ func BuildBundles(ctx context.Context, cfg *Global) error {
357356
cfg.OutDir = filepath.Join(cfg.Dir, "packages")
358357
}
359358

360-
jobs := runtime.GOMAXPROCS(0)
361-
cfg.jobch = make(chan struct{}, jobs)
362-
cfg.donech = make(chan *task, jobs)
359+
if cfg.Jobs == 0 {
360+
cfg.Jobs = runtime.GOMAXPROCS(0)
361+
}
362+
cfg.jobch = make(chan struct{}, cfg.Jobs)
363+
cfg.donech = make(chan *task, cfg.Jobs)
363364

364365
var mu sync.Mutex
365366
cfg.exists = map[string]map[string]struct{}{}
@@ -685,6 +686,7 @@ type Global struct {
685686

686687
dryrun bool
687688

689+
Jobs int
688690
jobch chan struct{}
689691
donech chan *task
690692

0 commit comments

Comments
 (0)