Skip to content

Commit

Permalink
refactor: refactor createLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Sep 29, 2022
1 parent 8eb0f38 commit 40154d3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/installpackage/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/aquaproj/aqua/pkg/checksum"
"github.com/aquaproj/aqua/pkg/config"
"github.com/aquaproj/aqua/pkg/config/aqua"
"github.com/aquaproj/aqua/pkg/config/registry"
"github.com/aquaproj/aqua/pkg/domain"
"github.com/aquaproj/aqua/pkg/link"
Expand Down Expand Up @@ -41,7 +40,11 @@ func isWindows(goos string) bool {
}

func (inst *Installer) InstallPackages(ctx context.Context, logE *logrus.Entry, param *domain.ParamInstallPackages) error { //nolint:funlen,cyclop
pkgs, failed := inst.createLinks(logE, param.Config, param.Registries)
pkgs, failed := config.ListPackages(logE, param.Config, inst.runtime, param.Registries)
if failedCreateLinks := inst.createLinks(logE, pkgs); !failedCreateLinks {
failed = failedCreateLinks
}

if inst.onlyLink {
logE.WithFields(logrus.Fields{
"only_link": true,
Expand Down Expand Up @@ -161,8 +164,8 @@ func (inst *Installer) InstallPackage(ctx context.Context, logE *logrus.Entry, p
return nil
}

func (inst *Installer) createLinks(logE *logrus.Entry, cfg *aqua.Config, registries map[string]*registry.Config) ([]*config.Package, bool) {
pkgs, failed := config.ListPackages(logE, cfg, inst.runtime, registries)
func (inst *Installer) createLinks(logE *logrus.Entry, pkgs []*config.Package) bool {
failed := false
for _, pkg := range pkgs {
pkgInfo := pkg.PackageInfo
for _, file := range pkgInfo.GetFiles() {
Expand All @@ -180,7 +183,7 @@ func (inst *Installer) createLinks(logE *logrus.Entry, cfg *aqua.Config, registr
}
}
}
return pkgs, failed
return failed
}

const maxRetryDownload = 1
Expand Down

0 comments on commit 40154d3

Please sign in to comment.