Skip to content

Commit

Permalink
override repository when creating deployment
Browse files Browse the repository at this point in the history
Signed-off-by: golemiso <3282656+golemiso@users.noreply.github.com>
  • Loading branch information
golemiso committed Mar 7, 2024
1 parent 4ec3e87 commit dab442a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 4 additions & 6 deletions pkg/app/piped/controller/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,10 @@ func (p *planner) Run(ctx context.Context) error {
p.done.Store(true)
}()

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)
repoCfg := config.PipedRepository{
RepoID: p.deployment.GitPath.Repo.Id,
Remote: p.deployment.GitPath.Repo.Remote,
Branch: p.deployment.GitPath.Repo.Branch,
}

in := pln.Input{
Expand Down
10 changes: 4 additions & 6 deletions pkg/app/piped/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,10 @@ func (s *scheduler) Run(ctx context.Context) error {
)
deploymentStatus = model.DeploymentStatus_DEPLOYMENT_SUCCESS

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, "")
repoCfg := config.PipedRepository{
RepoID: s.deployment.GitPath.Repo.Id,
Remote: s.deployment.GitPath.Repo.Remote,
Branch: s.deployment.GitPath.Repo.Branch,
}

s.targetDSP = deploysource.NewProvider(
Expand Down
6 changes: 5 additions & 1 deletion pkg/app/piped/trigger/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t *Trigger) triggerDeployment(
return nil
}

func buildDeployment(
func (t *Trigger) buildDeployment(
app *model.Application,
branch string,
commit git.Commit,
Expand All @@ -55,6 +55,10 @@ func buildDeployment(

var commitURL string
if r := app.GitPath.Repo; r != nil {
if repo, ok := t.config.GetRepository(r.Id); ok {
r.Branch = repo.Branch
r.Remote = repo.Remote
}
url, err := git.MakeCommitURL(r.Remote, commit.Hash)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (t *Trigger) checkRepoCandidates(ctx context.Context, repoID string, cs []c
}

// Build the deployment to trigger.
deployment, err := buildDeployment(
deployment, err := t.buildDeployment(
app,
branch,
headCommit,
Expand Down

0 comments on commit dab442a

Please sign in to comment.