Commit 4f7b4e0c
4f7b4e0cf9c0Merged
Dmitriy Zhilyaev <[email protected]> ยท 2 years ago ยท 1 file ยท ~1 modified
Description
feat: limiter parallel builder manifests
Signed-off-by: Dmitriy Zhilyaev [email protected]
Details
- Commit
- 4f7b4e0cf9c0
- Parent
- eee4e6a0ec6e
pkg/plan/build_manifests.gomodifiedView file
@@ -5,7 +5,8 @@
55
"fmt"66
"sync"77
8-
"github.com/helmwave/helmwave/pkg/parallel"8+
"golang.org/x/sync/errgroup"9+
910
"github.com/helmwave/helmwave/pkg/release"1011
log "github.com/sirupsen/logrus"1112
)@@ -13,21 +14,23 @@
1314
func (p *Plan) buildManifest(ctx context.Context) error {1415
log.Info("๐จ Building manifests...")1516
16-
wg := parallel.NewWaitGroup()17-
wg.Add(len(p.body.Releases))17+
wg, ctx := errgroup.WithContext(ctx)18+
wg.SetLimit(p.ParallelLimiter(ctx))1819
1920
mu := &sync.Mutex{}2021
2122
for _, rel := range p.body.Releases {22-
go p.buildReleaseManifest(ctx, wg, rel, mu)23+
wg.Go(24+
func() error {25+
return p.buildReleaseManifest(ctx, rel, mu)26+
})2327
}2428
29+
//nolint:wrapcheck2530
return wg.Wait()2631
}2732
28-
func (p *Plan) buildReleaseManifest(ctx context.Context, wg *parallel.WaitGroup, rel release.Config, mu *sync.Mutex) {29-
defer wg.Done()30-
33+
func (p *Plan) buildReleaseManifest(ctx context.Context, rel release.Config, mu *sync.Mutex) error {3134
l := rel.Logger()3235
3336
if err := rel.ChartDepsUpd(); err != nil {@@ -37,9 +40,8 @@
3740
r, err := rel.SyncDryRun(ctx, true)3841
if err != nil || r == nil {3942
l.Errorf("โ can't get manifests: %v", err)40-
wg.ErrChan() <- err4143
42-
return44+
return err4345
}4446
4547
hm := ""@@ -61,4 +63,6 @@
6163
mu.Unlock()6264
6365
l.Info("โ
manifest done")66+
67+
return nil6468
}