From a922c777c62653a3bb8f3be84a9deb4d2bc3df91 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 10 Oct 2023 09:47:24 +0900 Subject: [PATCH] fix: set github client --- pkg/controller/update/controller.go | 5 +++-- pkg/controller/update/registry.go | 2 +- pkg/controller/wire.go | 1 + pkg/controller/wire_gen.go | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/controller/update/controller.go b/pkg/controller/update/controller.go index 3d910b25d..e097ded8b 100644 --- a/pkg/controller/update/controller.go +++ b/pkg/controller/update/controller.go @@ -12,7 +12,7 @@ import ( ) type Controller struct { - github RepositoriesService + gh RepositoriesService rootDir string configFinder ConfigFinder configReader reader.ConfigReader @@ -28,8 +28,9 @@ type RepositoriesService interface { ListTags(ctx context.Context, owner string, repo string, opts *github.ListOptions) ([]*github.RepositoryTag, *github.Response, error) } -func New(param *config.Param, configFinder ConfigFinder, configReader reader.ConfigReader, registInstaller registry.Installer, fs afero.Fs, rt *runtime.Runtime) *Controller { +func New(param *config.Param, gh RepositoriesService, configFinder ConfigFinder, configReader reader.ConfigReader, registInstaller registry.Installer, fs afero.Fs, rt *runtime.Runtime) *Controller { return &Controller{ + gh: gh, rootDir: param.RootDir, configFinder: configFinder, configReader: configReader, diff --git a/pkg/controller/update/registry.go b/pkg/controller/update/registry.go index 4c89328a5..efaaabd40 100644 --- a/pkg/controller/update/registry.go +++ b/pkg/controller/update/registry.go @@ -14,7 +14,7 @@ func (c *Controller) newRegistryVersion(ctx context.Context, logE *logrus.Entry, } logE.Debug("getting the latest release") - release, _, err := c.github.GetLatestRelease(ctx, rgst.RepoOwner, rgst.RepoName) + release, _, err := c.gh.GetLatestRelease(ctx, rgst.RepoOwner, rgst.RepoName) if err != nil { return "", fmt.Errorf("get the latest release by GitHub API: %w", err) } diff --git a/pkg/controller/wire.go b/pkg/controller/wire.go index 19a8409cf..eb7e26a50 100644 --- a/pkg/controller/wire.go +++ b/pkg/controller/wire.go @@ -736,6 +736,7 @@ func InitializeUpdateCommandController(ctx context.Context, param *config.Param, wire.NewSet( github.New, wire.Bind(new(github.RepositoriesService), new(*github.RepositoriesServiceImpl)), + wire.Bind(new(update.RepositoriesService), new(*github.RepositoriesServiceImpl)), wire.Bind(new(download.GitHubContentAPI), new(*github.RepositoriesServiceImpl)), ), wire.NewSet( diff --git a/pkg/controller/wire_gen.go b/pkg/controller/wire_gen.go index b56116e25..bfbf60e81 100644 --- a/pkg/controller/wire_gen.go +++ b/pkg/controller/wire_gen.go @@ -259,10 +259,10 @@ func InitializeUpdateChecksumCommandController(ctx context.Context, param *confi } func InitializeUpdateCommandController(ctx context.Context, param *config.Param, httpClient *http.Client, rt *runtime.Runtime) *update.Controller { + repositoriesService := github.New(ctx) fs := afero.NewOsFs() configFinder := finder.NewConfigFinder(fs) configReaderImpl := reader.New(fs, param) - repositoriesService := github.New(ctx) httpDownloader := download.NewHTTPDownloader(httpClient) gitHubContentFileDownloader := download.NewGitHubContentFileDownloader(repositoriesService, httpDownloader) executor := exec.New() @@ -271,7 +271,7 @@ func InitializeUpdateCommandController(ctx context.Context, param *config.Param, executorImpl := slsa.NewExecutor(executor, param) slsaVerifierImpl := slsa.New(downloader, fs, executorImpl) installerImpl := registry.New(param, gitHubContentFileDownloader, fs, rt, verifierImpl, slsaVerifierImpl) - controller := update.New(param, configFinder, configReaderImpl, installerImpl, fs, rt) + controller := update.New(param, repositoriesService, configFinder, configReaderImpl, installerImpl, fs, rt) return controller }