From 07fcc264bf67ecfbaa2827e646aead87042140c8 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sun, 12 Jan 2025 00:03:59 +0900 Subject: [PATCH] fix: replace time.Sleep with timer.Wait to support cancel --- pkg/cli/vacuum/command.go | 4 +- pkg/controller/install/install_test.go | 2 +- pkg/controller/vacuum/controller.go | 7 ++- pkg/controller/vacuum/queue_store.go | 11 ++-- pkg/controller/vacuum/vacuum.go | 53 ++++++++-------- pkg/controller/vacuum/vacuum_internal_test.go | 3 +- pkg/controller/vacuum/vacuum_test.go | 62 +++++++++++-------- pkg/controller/wire_gen.go | 6 +- 8 files changed, 80 insertions(+), 68 deletions(-) diff --git a/pkg/cli/vacuum/command.go b/pkg/cli/vacuum/command.go index 80fa08d4b..1ed9ea348 100644 --- a/pkg/cli/vacuum/command.go +++ b/pkg/cli/vacuum/command.go @@ -86,14 +86,14 @@ func (i *command) action(c *cli.Context) error { ctrl := controller.InitializeVacuumCommandController(c.Context, param, http.DefaultClient, i.r.Runtime) if c.Command.Name == "show" { - if err := ctrl.ListPackages(i.r.LogE, c.Bool("expired")); err != nil { + if err := ctrl.ListPackages(c.Context, i.r.LogE, c.Bool("expired")); err != nil { return fmt.Errorf("show packages: %w", err) } return nil } if c.Command.Name == "run" { - if err := ctrl.Vacuum(i.r.LogE); err != nil { + if err := ctrl.Vacuum(c.Context, i.r.LogE); err != nil { return fmt.Errorf("run: %w", err) } } diff --git a/pkg/controller/install/install_test.go b/pkg/controller/install/install_test.go index 25e81ef67..6741797c5 100644 --- a/pkg/controller/install/install_test.go +++ b/pkg/controller/install/install_test.go @@ -104,7 +104,7 @@ packages: } downloader := download.NewDownloader(nil, download.NewHTTPDownloader(http.DefaultClient)) executor := &osexec.Mock{} - vacuum := vacuum.New(d.param, fs) + vacuum := vacuum.New(ctx, d.param, fs) pkgInstaller := installpackage.New(d.param, downloader, d.rt, fs, linker, nil, &checksum.Calculator{}, unarchive.New(executor, fs), &cosign.MockVerifier{}, &slsa.MockVerifier{}, &minisign.MockVerifier{}, &ghattestation.MockVerifier{}, &installpackage.MockGoInstallInstaller{}, &installpackage.MockGoBuildInstaller{}, &installpackage.MockCargoPackageInstaller{}, vacuum) policyFinder := policy.NewConfigFinder(fs) policyReader := policy.NewReader(fs, &policy.MockValidator{}, policyFinder, policy.NewConfigReader(fs)) diff --git a/pkg/controller/vacuum/controller.go b/pkg/controller/vacuum/controller.go index 4431486ee..de886cb48 100644 --- a/pkg/controller/vacuum/controller.go +++ b/pkg/controller/vacuum/controller.go @@ -1,6 +1,7 @@ package vacuum import ( + "context" "fmt" "io" "os" @@ -26,13 +27,13 @@ type Controller struct { } // New initializes a Controller with the given context, parameters, and dependencies. -func New(param *config.Param, fs afero.Fs) *Controller { +func New(ctx context.Context, param *config.Param, fs afero.Fs) *Controller { vc := &Controller{ stdout: os.Stdout, Param: param, fs: fs, } - vc.storeQueue = newStoreQueue(vc) + vc.storeQueue = newStoreQueue(ctx, vc) return vc } @@ -73,7 +74,7 @@ func (vc *Controller) getDB() (*bolt.DB, error) { } // withDBRetry retries a database operation with exponential backoff. -func (vc *Controller) withDBRetry(logE *logrus.Entry, fn func(*bolt.Tx) error, dbAccessType DBAccessType) error { +func (vc *Controller) withDBRetry(ctx context.Context, logE *logrus.Entry, fn func(*bolt.Tx) error, dbAccessType DBAccessType) error { const ( retries = 2 initialBackoff = 100 * time.Millisecond diff --git a/pkg/controller/vacuum/queue_store.go b/pkg/controller/vacuum/queue_store.go index f8e69b49b..f12a842c7 100644 --- a/pkg/controller/vacuum/queue_store.go +++ b/pkg/controller/vacuum/queue_store.go @@ -1,6 +1,7 @@ package vacuum import ( + "context" "sync" "github.com/sirupsen/logrus" @@ -23,7 +24,7 @@ type StoreQueue struct { } // newStoreQueue initializes the task queue with a single worker. -func newStoreQueue(vc *Controller) *StoreQueue { +func newStoreQueue(ctx context.Context, vc *Controller) *StoreQueue { const maxTasks = 100 sq := &StoreQueue{ taskQueue: make(chan StoreRequest, maxTasks), @@ -31,19 +32,19 @@ func newStoreQueue(vc *Controller) *StoreQueue { vc: vc, } - go sq.worker() + go sq.worker(ctx) return sq } // worker processes tasks from the queue. -func (sq *StoreQueue) worker() { +func (sq *StoreQueue) worker(ctx context.Context) { for { select { case task, ok := <-sq.taskQueue: if !ok { return } - err := sq.vc.storePackageInternal(task.logE, task.pkg) + err := sq.vc.storePackageInternal(ctx, task.logE, task.pkg) if err != nil { logerr.WithError(task.logE, err).Error("store package asynchronously") } @@ -52,7 +53,7 @@ func (sq *StoreQueue) worker() { // Process remaining tasks for len(sq.taskQueue) > 0 { task := <-sq.taskQueue - err := sq.vc.storePackageInternal(task.logE, task.pkg) + err := sq.vc.storePackageInternal(ctx, task.logE, task.pkg) if err != nil { logerr.WithError(task.logE, err).Error("store package asynchronously during shutdown") } diff --git a/pkg/controller/vacuum/vacuum.go b/pkg/controller/vacuum/vacuum.go index 7ca166b3a..ff80891fb 100644 --- a/pkg/controller/vacuum/vacuum.go +++ b/pkg/controller/vacuum/vacuum.go @@ -1,6 +1,7 @@ package vacuum import ( + "context" "encoding/json" "errors" "fmt" @@ -46,26 +47,26 @@ type Package struct { } // Vacuum performs the vacuuming process if it is enabled. -func (vc *Controller) Vacuum(logE *logrus.Entry) error { +func (vc *Controller) Vacuum(ctx context.Context, logE *logrus.Entry) error { if !vc.IsVacuumEnabled(logE) { return nil } - return vc.vacuumExpiredPackages(logE) + return vc.vacuumExpiredPackages(ctx, logE) } // ListPackages lists the packages based on the provided arguments. // If the expired flag is set to true, it lists the expired packages. // Otherwise, it lists all packages. -func (vc *Controller) ListPackages(logE *logrus.Entry, expired bool, args ...string) error { +func (vc *Controller) ListPackages(ctx context.Context, logE *logrus.Entry, expired bool, args ...string) error { if expired { - return vc.handleListExpiredPackages(logE, args...) + return vc.handleListExpiredPackages(ctx, logE, args...) } - return vc.handleListPackages(logE, args...) + return vc.handleListPackages(ctx, logE, args...) } // handleListPackages retrieves a list of packages and displays them using a fuzzy search. -func (vc *Controller) handleListPackages(logE *logrus.Entry, args ...string) error { - pkgs, err := vc.listPackages(logE) +func (vc *Controller) handleListPackages(ctx context.Context, logE *logrus.Entry, args ...string) error { + pkgs, err := vc.listPackages(ctx, logE) if err != nil { return err } @@ -74,8 +75,8 @@ func (vc *Controller) handleListPackages(logE *logrus.Entry, args ...string) err // handleListExpiredPackages handles the process of listing expired packages // and displaying them using a fuzzy search. -func (vc *Controller) handleListExpiredPackages(logE *logrus.Entry, args ...string) error { - expiredPkgs, err := vc.listExpiredPackages(logE) +func (vc *Controller) handleListExpiredPackages(ctx context.Context, logE *logrus.Entry, args ...string) error { + expiredPkgs, err := vc.listExpiredPackages(ctx, logE) if err != nil { return err } @@ -135,8 +136,8 @@ func (vc *Controller) IsVacuumEnabled(logE *logrus.Entry) bool { } // listExpiredPackages lists all packages that have expired based on the vacuum configuration. -func (vc *Controller) listExpiredPackages(logE *logrus.Entry) ([]*PackageVacuumEntry, error) { - pkgs, err := vc.listPackages(logE) +func (vc *Controller) listExpiredPackages(ctx context.Context, logE *logrus.Entry) ([]*PackageVacuumEntry, error) { + pkgs, err := vc.listPackages(ctx, logE) if err != nil { return nil, err } @@ -165,7 +166,7 @@ func (vc *Controller) isPackageExpired(pkg *PackageVacuumEntry) bool { } // listPackages lists all stored package entries. -func (vc *Controller) listPackages(logE *logrus.Entry) ([]*PackageVacuumEntry, error) { +func (vc *Controller) listPackages(ctx context.Context, logE *logrus.Entry) ([]*PackageVacuumEntry, error) { db, err := vc.getDB() if err != nil { return nil, err @@ -177,7 +178,7 @@ func (vc *Controller) listPackages(logE *logrus.Entry) ([]*PackageVacuumEntry, e var pkgs []*PackageVacuumEntry - err = vc.withDBRetry(logE, func(tx *bbolt.Tx) error { + err = vc.withDBRetry(ctx, logE, func(tx *bbolt.Tx) error { b := tx.Bucket([]byte(bucketNamePkgs)) if b == nil { return nil @@ -279,8 +280,8 @@ func (vc *Controller) displayPackagesFuzzyInteractive(pkgs []*PackageVacuumEntry } // vacuumExpiredPackages performs cleanup of expired packages. -func (vc *Controller) vacuumExpiredPackages(logE *logrus.Entry) error { - expiredPackages, err := vc.listExpiredPackages(logE) +func (vc *Controller) vacuumExpiredPackages(ctx context.Context, logE *logrus.Entry) error { + expiredPackages, err := vc.listExpiredPackages(ctx, logE) if err != nil { return err } @@ -303,7 +304,7 @@ func (vc *Controller) vacuumExpiredPackages(logE *logrus.Entry) error { defer vc.Close(logE) if len(successfulRemovals) > 0 { - if err := vc.removePackages(logE, successfulRemovals); err != nil { + if err := vc.removePackages(ctx, logE, successfulRemovals); err != nil { return fmt.Errorf("remove packages from database: %w", err) } } @@ -374,12 +375,12 @@ func (vc *Controller) processExpiredPackages(logE *logrus.Entry, expired []*Pack } // storePackageInternal stores package entries in the database. -func (vc *Controller) storePackageInternal(logE *logrus.Entry, pkg *Package, dateTime ...time.Time) error { +func (vc *Controller) storePackageInternal(ctx context.Context, logE *logrus.Entry, pkg *Package, dateTime ...time.Time) error { lastUsedTime := time.Now() if len(dateTime) > 0 { lastUsedTime = dateTime[0] } - return vc.withDBRetry(logE, func(tx *bbolt.Tx) error { + return vc.withDBRetry(ctx, logE, func(tx *bbolt.Tx) error { b := tx.Bucket([]byte(bucketNamePkgs)) if b == nil { return errors.New("bucket not found") @@ -416,8 +417,8 @@ func (vc *Controller) storePackageInternal(logE *logrus.Entry, pkg *Package, dat } // removePackages removes package entries from the database. -func (vc *Controller) removePackages(logE *logrus.Entry, pkgs []string) error { - return vc.withDBRetry(logE, func(tx *bbolt.Tx) error { +func (vc *Controller) removePackages(ctx context.Context, logE *logrus.Entry, pkgs []string) error { + return vc.withDBRetry(ctx, logE, func(tx *bbolt.Tx) error { b := tx.Bucket([]byte(bucketNamePkgs)) if b == nil { return errors.New("bucket not found") @@ -462,9 +463,9 @@ func decodePackageEntry(data []byte) (*PackageEntry, error) { } // GetPackageLastUsed retrieves the last used time of a package. for testing purposes. -func (vc *Controller) GetPackageLastUsed(logE *logrus.Entry, pkgPath string) *time.Time { +func (vc *Controller) GetPackageLastUsed(ctx context.Context, logE *logrus.Entry, pkgPath string) *time.Time { var lastUsedTime time.Time - pkgEntry, _ := vc.retrievePackageEntry(logE, pkgPath) + pkgEntry, _ := vc.retrievePackageEntry(ctx, logE, pkgPath) if pkgEntry != nil { lastUsedTime = pkgEntry.LastUsageTime } @@ -472,16 +473,16 @@ func (vc *Controller) GetPackageLastUsed(logE *logrus.Entry, pkgPath string) *ti } // SetTimeStampPackage permit define a Timestamp for a package Manually. for testing purposes. -func (vc *Controller) SetTimestampPackage(logE *logrus.Entry, pkg *config.Package, pkgPath string, datetime time.Time) error { +func (vc *Controller) SetTimestampPackage(ctx context.Context, logE *logrus.Entry, pkg *config.Package, pkgPath string, datetime time.Time) error { vacuumPkg := vc.getVacuumPackage(pkg, pkgPath) - return vc.storePackageInternal(logE, vacuumPkg, datetime) + return vc.storePackageInternal(ctx, logE, vacuumPkg, datetime) } // retrievePackageEntry retrieves a package entry from the database by key. for testing purposes. -func (vc *Controller) retrievePackageEntry(logE *logrus.Entry, key string) (*PackageEntry, error) { +func (vc *Controller) retrievePackageEntry(ctx context.Context, logE *logrus.Entry, key string) (*PackageEntry, error) { var pkgEntry *PackageEntry key = generatePackageKey(vc.Param.RootDir, key) - err := vc.withDBRetry(logE, func(tx *bbolt.Tx) error { + err := vc.withDBRetry(ctx, logE, func(tx *bbolt.Tx) error { b := tx.Bucket([]byte(bucketNamePkgs)) if b == nil { return nil diff --git a/pkg/controller/vacuum/vacuum_internal_test.go b/pkg/controller/vacuum/vacuum_internal_test.go index 1b6d9f8cb..7f6c75714 100644 --- a/pkg/controller/vacuum/vacuum_internal_test.go +++ b/pkg/controller/vacuum/vacuum_internal_test.go @@ -1,6 +1,7 @@ package vacuum import ( + "context" "encoding/json" "testing" "time" @@ -14,7 +15,7 @@ func TestHandleAsyncStorePackage_NilPackage(t *testing.T) { t.Parallel() logE := logrus.NewEntry(logrus.New()) - vacuumCtrl := New(nil, nil) + vacuumCtrl := New(context.Background(), nil, nil) // Test err := vacuumCtrl.handleAsyncStorePackage(logE, nil) diff --git a/pkg/controller/vacuum/vacuum_test.go b/pkg/controller/vacuum/vacuum_test.go index ba26eca07..e35015284 100644 --- a/pkg/controller/vacuum/vacuum_test.go +++ b/pkg/controller/vacuum/vacuum_test.go @@ -1,6 +1,7 @@ package vacuum_test import ( + "context" "path/filepath" "testing" "time" @@ -42,12 +43,13 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop param := &config.Param{ RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") require.NoError(t, err, "Should return nil when vacuum is disabled") - err = controller.Vacuum(logE) + err = controller.Vacuum(ctx, logE) require.NoError(t, err, "Should return nil when vacuum is disabled") err = controller.Close(logE) @@ -64,7 +66,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop RootDir: testDir, VacuumDays: -1, } - controller := vacuum.New(param, fs) + controller := vacuum.New(context.Background(), param, fs) err = controller.StorePackage(logE, nil, testDir) require.NoError(t, err, "Should return nil when vacuum is disabled") @@ -82,10 +84,11 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) // Test - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") // Assert require.NoError(t, err) // Should succeed with empty database @@ -102,7 +105,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + controller := vacuum.New(context.Background(), param, fs) numberPackagesToStore := 7 pkgs := generateTestPackages(numberPackagesToStore, param.RootDir) @@ -146,7 +149,8 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) numberPackagesToStore := 1 pkgs := generateTestPackages(numberPackagesToStore, param.RootDir) @@ -159,7 +163,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop require.NoError(t, err) // List packages - should contain our stored package - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") require.NoError(t, err) assert.Equal(t, "Test mode: Displaying packages", hook.LastEntry().Message) assert.Equal(t, 1, hook.LastEntry().Data["TotalPackages"]) @@ -167,7 +171,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop hook.Reset() // Verify package was stored correctly - lastUsed := controller.GetPackageLastUsed(logE, pkgs[0].pkgPath) + lastUsed := controller.GetPackageLastUsed(ctx, logE, pkgs[0].pkgPath) assert.False(t, lastUsed.IsZero(), "Package should have a last used time") }) @@ -181,7 +185,8 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) numberPackagesToStore := 4 pkgs := generateTestPackages(numberPackagesToStore, param.RootDir) @@ -196,7 +201,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop require.NoError(t, err) // List packages - should contain our stored package - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") require.NoError(t, err) assert.Equal(t, "Test mode: Displaying packages", hook.LastEntry().Message) assert.Equal(t, 4, hook.LastEntry().Data["TotalPackages"]) @@ -214,7 +219,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + controller := vacuum.New(context.Background(), param, fs) // Store the package err = controller.StorePackage(logE, nil, tempTestDir) @@ -232,10 +237,11 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) // Test - err = controller.ListPackages(logE, true, "test") + err = controller.ListPackages(ctx, logE, true, "test") // Assert require.NoError(t, err) // Error if no package found @@ -255,7 +261,8 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) numberPackagesToStore := 3 numberPackagesToExpire := 1 @@ -288,28 +295,28 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop // Modify timestamp of one package to be expired oldTime := time.Now().Add(-48 * time.Hour) // 2 days old for _, pkg := range pkgs[:numberPackagesToExpire] { - err = controller.SetTimestampPackage(logE, pkg.configPkg, pkg.pkgPath, oldTime) + err = controller.SetTimestampPackage(ctx, logE, pkg.configPkg, pkg.pkgPath, oldTime) require.NoError(t, err) } // Check Packages after expiration - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") require.NoError(t, err) assert.Equal(t, numberPackagesToStore, hook.LastEntry().Data["TotalPackages"]) assert.Equal(t, numberPackagesToExpire, hook.LastEntry().Data["TotalExpired"]) // List expired packages only - err = controller.ListPackages(logE, true, "test") + err = controller.ListPackages(ctx, logE, true, "test") require.NoError(t, err) assert.Equal(t, numberPackagesToExpire, hook.LastEntry().Data["TotalPackages"]) assert.Equal(t, numberPackagesToExpire, hook.LastEntry().Data["TotalExpired"]) // Run vacuum - err = controller.Vacuum(logE) + err = controller.Vacuum(ctx, logE) require.NoError(t, err) // List expired packages - err = controller.ListPackages(logE, true, "test") + err = controller.ListPackages(ctx, logE, true, "test") require.NoError(t, err) assert.Equal(t, "no packages to display", hook.LastEntry().Message) @@ -322,7 +329,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop // Modify timestamp of one package to be expired And lock DB to simulate a failure in the vacuum operation for _, pkg := range pkgs[:numberPackagesToExpire] { - err = controller.SetTimestampPackage(logE, pkg.configPkg, pkg.pkgPath, oldTime) + err = controller.SetTimestampPackage(ctx, logE, pkg.configPkg, pkg.pkgPath, oldTime) require.NoError(t, err) } @@ -331,7 +338,7 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop require.NoError(t, err) // Run vacuum - err = controller.Vacuum(logE) + err = controller.Vacuum(ctx, logE) require.Error(t, err) assert.Contains(t, err.Error(), "open database vacuum.db: timeout") }) @@ -347,7 +354,8 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop VacuumDays: days, RootDir: testDir, } - controller := vacuum.New(param, fs) + ctx := context.Background() + controller := vacuum.New(ctx, param, fs) // Store non-expired packages pkgs := generateTestPackages(3, param.RootDir) @@ -361,11 +369,11 @@ func TestVacuum(t *testing.T) { //nolint:funlen,maintidx,cyclop require.NoError(t, err) // Run vacuum - err = controller.Vacuum(logE) + err = controller.Vacuum(ctx, logE) require.NoError(t, err) // Verify no packages were removed - err = controller.ListPackages(logE, false, "test") + err = controller.ListPackages(ctx, logE, false, "test") require.NoError(t, err) assert.Equal(t, 3, hook.LastEntry().Data["TotalPackages"]) }) @@ -500,7 +508,7 @@ func benchmarkVacuumStorePackages(b *testing.B, pkgCount int) { }() b.Run("Sync", func(b *testing.B) { - controller := vacuum.New(syncParam, fs) + controller := vacuum.New(context.Background(), syncParam, fs) b.ResetTimer() for range b.N { for _, pkg := range pkgs { diff --git a/pkg/controller/wire_gen.go b/pkg/controller/wire_gen.go index 112c81e99..249c33249 100644 --- a/pkg/controller/wire_gen.go +++ b/pkg/controller/wire_gen.go @@ -150,7 +150,7 @@ func InitializeInstallCommandController(ctx context.Context, param *config.Param goInstallInstallerImpl := installpackage.NewGoInstallInstallerImpl(executor) goBuildInstallerImpl := installpackage.NewGoBuildInstallerImpl(executor) cargoPackageInstallerImpl := installpackage.NewCargoPackageInstallerImpl(executor, fs) - controller := vacuum.New(param, fs) + controller := vacuum.New(ctx, param, fs) installpackageInstaller := installpackage.New(param, downloader, rt, fs, linker, checksumDownloaderImpl, calculator, unarchiver, verifier, slsaVerifier, minisignVerifier, ghattestationVerifier, goInstallInstallerImpl, goBuildInstallerImpl, cargoPackageInstallerImpl, controller) validatorImpl := policy.NewValidator(param, fs) configFinderImpl := policy.NewConfigFinder(fs) @@ -205,7 +205,7 @@ func InitializeExecCommandController(ctx context.Context, param *config.Param, h goInstallInstallerImpl := installpackage.NewGoInstallInstallerImpl(executor) goBuildInstallerImpl := installpackage.NewGoBuildInstallerImpl(executor) cargoPackageInstallerImpl := installpackage.NewCargoPackageInstallerImpl(executor, fs) - controller := vacuum.New(param, fs) + controller := vacuum.New(ctx, param, fs) installer := installpackage.New(param, downloader, rt, fs, linker, checksumDownloaderImpl, calculator, unarchiver, verifier, slsaVerifier, minisignVerifier, ghattestationVerifier, goInstallInstallerImpl, goBuildInstallerImpl, cargoPackageInstallerImpl, controller) configFinder := finder.NewConfigFinder(fs) configReader := reader.New(fs, param) @@ -389,7 +389,7 @@ func InitializeRemoveCommandController(ctx context.Context, param *config.Param, func InitializeVacuumCommandController(ctx context.Context, param *config.Param, httpClient *http.Client, rt *runtime.Runtime) *vacuum.Controller { fs := afero.NewOsFs() - controller := vacuum.New(param, fs) + controller := vacuum.New(ctx, param, fs) return controller }