Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix a bug that AQUA_DISABLE_POLIDY doesn't work #2415

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controller/cp/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *Controller) installAndCopy(ctx context.Context, logE *logrus.Entry, par
return err //nolint:wrapcheck
}

if err := c.install(ctx, logE, findResult, policyConfigs); err != nil {
if err := c.install(ctx, logE, findResult, policyConfigs, param); err != nil {
return err
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/cp/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"path/filepath"

"github.com/aquaproj/aqua/v2/pkg/checksum"
"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/controller/which"
"github.com/aquaproj/aqua/v2/pkg/installpackage"
"github.com/aquaproj/aqua/v2/pkg/policy"
"github.com/sirupsen/logrus"
"github.com/suzuki-shunsuke/logrus-error/logerr"
)

func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult *which.FindResult, policyConfigs []*policy.Config) error {
func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult *which.FindResult, policyConfigs []*policy.Config, param *config.Param) error {
var checksums *checksum.Checksums
if findResult.Config.ChecksumEnabled() {
checksums = checksum.New()
Expand All @@ -37,6 +38,7 @@ func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult
RequireChecksum: findResult.Config.RequireChecksum(c.requireChecksum),
ConfigFileDir: filepath.Dir(findResult.ConfigFilePath),
PolicyConfigs: policyConfigs,
DisablePolicy: param.DisablePolicy,
}); err != nil {
return fmt.Errorf("install a package: %w", logerr.WithFields(err, logE.Data))
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func (c *Controller) Exec(ctx context.Context, logE *logrus.Entry, param *config
return logerr.WithFields(errExecNotFoundDisableLazyInstall, logE.WithField("doc", "https://aquaproj.github.io/docs/reference/codes/006").Data) //nolint:wrapcheck
}
}
if err := c.install(ctx, logE, findResult, policyCfgs); err != nil {
if err := c.install(ctx, logE, findResult, policyCfgs, param); err != nil {
return err
}
return c.execCommandWithRetry(ctx, logE, findResult.ExePath, args...)
}

func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult *which.FindResult, policies []*policy.Config) error {
func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult *which.FindResult, policies []*policy.Config, param *config.Param) error {
var checksums *checksum.Checksums
if findResult.Config.ChecksumEnabled() {
checksums = checksum.New()
Expand All @@ -87,6 +87,7 @@ func (c *Controller) install(ctx context.Context, logE *logrus.Entry, findResult
Checksums: checksums,
RequireChecksum: findResult.Config.RequireChecksum(c.requireChecksum),
PolicyConfigs: policies,
DisablePolicy: param.DisablePolicy,
}); err != nil {
return fmt.Errorf("install the package: %w", err)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *Controller) Install(ctx context.Context, logE *logrus.Entry, param *con
if err != nil {
return err //nolint:wrapcheck
}
if err := c.install(ctx, logE, cfgFilePath, policyCfgs); err != nil {
if err := c.install(ctx, logE, cfgFilePath, policyCfgs, param); err != nil {
return err
}
}
Expand Down Expand Up @@ -78,14 +78,14 @@ func (c *Controller) installAll(ctx context.Context, logE *logrus.Entry, param *
if err != nil {
return err //nolint:wrapcheck
}
if err := c.install(ctx, logE, cfgFilePath, policyConfigs); err != nil {
if err := c.install(ctx, logE, cfgFilePath, policyConfigs, param); err != nil {
return err
}
}
return nil
}

func (c *Controller) install(ctx context.Context, logE *logrus.Entry, cfgFilePath string, policyConfigs []*policy.Config) error {
func (c *Controller) install(ctx context.Context, logE *logrus.Entry, cfgFilePath string, policyConfigs []*policy.Config, param *config.Param) error {
cfg := &aqua.Config{}
if cfgFilePath == "" {
return finder.ErrConfigFileNotFound
Expand Down Expand Up @@ -126,5 +126,6 @@ func (c *Controller) install(ctx context.Context, logE *logrus.Entry, cfgFilePat
PolicyConfigs: policyConfigs,
Checksums: checksums,
RequireChecksum: c.requireChecksum,
DisablePolicy: param.DisablePolicy,
})
}
2 changes: 2 additions & 0 deletions pkg/installpackage/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type ParamInstallPackages struct {
Checksums *checksum.Checksums
SkipLink bool
RequireChecksum bool
DisablePolicy bool
}

type ParamInstallPackage struct {
Expand Down Expand Up @@ -208,6 +209,7 @@ func (is *InstallerImpl) InstallPackages(ctx context.Context, logE *logrus.Entry
Checksums: param.Checksums,
RequireChecksum: param.Config.RequireChecksum(param.RequireChecksum),
PolicyConfigs: param.PolicyConfigs,
DisablePolicy: param.DisablePolicy,
}); err != nil {
logerr.WithError(logE, err).Error("install the package")
handleFailure()
Expand Down