Skip to content

Commit

Permalink
use promotion name when generating branch names
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
  • Loading branch information
krancour committed Oct 30, 2024
1 parent f30f66b commit 3b300f8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/controller/promotions/promotions.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ func (r *reconciler) promote(
WorkDir: filepath.Join(os.TempDir(), "promotion-"+string(workingPromo.UID)),
Project: stageNamespace,
Stage: stageName,
Promotion: workingPromo.Name,
FreightRequests: stage.Spec.RequestedFreight,
Freight: *workingPromo.Status.FreightCollection.DeepCopy(),
StartFromStep: promo.Status.CurrentStep,
Expand Down
2 changes: 1 addition & 1 deletion internal/directives/git_pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (g *gitPushPusher) runPromotionStep(
}
// If we're supposed to generate a target branch name, do so
if cfg.GenerateTargetBranch {
pushOpts.TargetBranch = fmt.Sprintf("kargo/%s/%s/promotion", stepCtx.Project, stepCtx.Stage)
pushOpts.TargetBranch = fmt.Sprintf("kargo/promotion/%s", stepCtx.Promotion)
pushOpts.Force = true
}
targetBranch := pushOpts.TargetBranch
Expand Down
3 changes: 2 additions & 1 deletion internal/directives/git_pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func Test_gitPusher_runPromotionStep(t *testing.T) {
&PromotionStepContext{
Project: "fake-project",
Stage: "fake-stage",
Promotion: "fake-promotion",
WorkDir: workDir,
CredentialsDB: &credentials.FakeDB{},
},
Expand All @@ -201,7 +202,7 @@ func Test_gitPusher_runPromotionStep(t *testing.T) {
require.NoError(t, err)
branchName, ok := res.Output[branchKey]
require.True(t, ok)
require.Equal(t, "kargo/fake-project/fake-stage/promotion", branchName)
require.Equal(t, "kargo/promotion/fake-promotion", branchName)
expectedCommit, err := workTree.LastCommitID()
require.NoError(t, err)
actualCommit, ok := res.Output[commitKey]
Expand Down
4 changes: 4 additions & 0 deletions internal/directives/promotions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type PromotionContext struct {
Project string
// Stage is the Stage that the Promotion is targeting.
Stage string
// Promotion is the name of the Promotion.
Promotion string
// FreightRequests is the list of Freight from various origins that is
// requested by the Stage targeted by the Promotion. This information is
// sometimes useful to PromotionSteps that reference a particular artifact
Expand Down Expand Up @@ -114,6 +116,8 @@ type PromotionStepContext struct {
Project string
// Stage is the Stage that the Promotion is targeting.
Stage string
// Promotion is the name of the Promotion.
Promotion string
// FreightRequests is the list of Freight from various origins that is
// requested by the Stage targeted by the Promotion. This information is
// sometimes useful to PromotionStep that reference a particular artifact and,
Expand Down
1 change: 1 addition & 0 deletions internal/directives/simple_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (e *SimpleEngine) Promote(
Config: step.Config.DeepCopy(),
Project: promoCtx.Project,
Stage: promoCtx.Stage,
Promotion: promoCtx.Promotion,
FreightRequests: promoCtx.FreightRequests,
Freight: promoCtx.Freight,
}
Expand Down

0 comments on commit 3b300f8

Please sign in to comment.