From 989d485b90b1d34c54852a7e08d44445dffa026f Mon Sep 17 00:00:00 2001 From: golemiso <3282656+golemiso@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:55:12 +0900 Subject: [PATCH] Use repository settings from piped config --- pkg/app/piped/controller/planner.go | 10 ++++++---- pkg/app/piped/controller/scheduler.go | 10 ++++++---- pkg/app/piped/planpreview/builder.go | 6 ------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/app/piped/controller/planner.go b/pkg/app/piped/controller/planner.go index 0beef633c2..6bd5f269c1 100644 --- a/pkg/app/piped/controller/planner.go +++ b/pkg/app/piped/controller/planner.go @@ -150,10 +150,12 @@ func (p *planner) Run(ctx context.Context) error { p.done.Store(true) }() - repoCfg := config.PipedRepository{ - RepoID: p.deployment.GitPath.Repo.Id, - Remote: p.deployment.GitPath.Repo.Remote, - Branch: p.deployment.GitPath.Repo.Branch, + repoID := p.deployment.GitPath.Repo.Id + repoCfg, ok := p.pipedConfig.GetRepository(repoID) + if !ok { + p.doneDeploymentStatus = model.DeploymentStatus_DEPLOYMENT_FAILURE + reason := fmt.Sprintf("Repository %s was not found in piped configuration", repoID) + return p.reportDeploymentFailed(ctx, reason) } in := pln.Input{ diff --git a/pkg/app/piped/controller/scheduler.go b/pkg/app/piped/controller/scheduler.go index 91e0bf63a2..42a3589f52 100644 --- a/pkg/app/piped/controller/scheduler.go +++ b/pkg/app/piped/controller/scheduler.go @@ -220,10 +220,12 @@ func (s *scheduler) Run(ctx context.Context) error { ) deploymentStatus = model.DeploymentStatus_DEPLOYMENT_SUCCESS - repoCfg := config.PipedRepository{ - RepoID: s.deployment.GitPath.Repo.Id, - Remote: s.deployment.GitPath.Repo.Remote, - Branch: s.deployment.GitPath.Repo.Branch, + repoID := s.deployment.GitPath.Repo.Id + repoCfg, ok := s.pipedConfig.GetRepository(repoID) + if !ok { + deploymentStatus := model.DeploymentStatus_DEPLOYMENT_FAILURE + statusReason := fmt.Sprintf("Repository %s was not found in piped configuration", repoID) + return s.reportDeploymentCompleted(ctx, deploymentStatus, statusReason, "") } s.targetDSP = deploysource.NewProvider( diff --git a/pkg/app/piped/planpreview/builder.go b/pkg/app/piped/planpreview/builder.go index 1a307ea259..fe827e9161 100644 --- a/pkg/app/piped/planpreview/builder.go +++ b/pkg/app/piped/planpreview/builder.go @@ -377,12 +377,6 @@ func (b *builder) listApplications(repo config.PipedRepository) []*model.Applica if app.GitPath.Repo.Id != repo.RepoID { continue } - if app.GitPath.Repo.Remote != repo.Remote { - continue - } - if app.GitPath.Repo.Branch != repo.Branch { - continue - } out = append(out, app) }