Skip to content

Commit

Permalink
corresponding directive updates
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <[email protected]>
  • Loading branch information
krancour committed Sep 30, 2024
1 parent 44115a4 commit bc4c654
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions internal/directives/git_pr_waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,28 @@ func (g *gitPRWaiter) runPromotionStep(
}

func getPRNumber(sharedState State, cfg GitWaitForPRConfig) (int64, error) {
if cfg.PRNumberFromOpen == "" {
if cfg.PRNumberFromStep == "" {
return cfg.PRNumber, nil
}
stepOutput, exists := sharedState.Get(cfg.PRNumberFromOpen)
stepOutput, exists := sharedState.Get(cfg.PRNumberFromStep)
if !exists {
return 0, fmt.Errorf(
"no output found from step with alias %q",
cfg.PRNumberFromOpen,
cfg.PRNumberFromStep,
)
}
stepOutputMap, ok := stepOutput.(map[string]any)
if !ok {
return 0, fmt.Errorf(
"output from step with alias %q is not a map[string]any",
cfg.PRNumberFromOpen,
cfg.PRNumberFromStep,
)
}
prNumberAny, exists := stepOutputMap[prNumberKey]
if !exists {
return 0, fmt.Errorf(
"no PR number found in output from step with alias %q",
cfg.PRNumberFromOpen,
cfg.PRNumberFromStep,
)
}
// If the state was rehydrated from PromotionStatus, which makes use of
Expand All @@ -166,7 +166,7 @@ func getPRNumber(sharedState State, cfg GitWaitForPRConfig) (int64, error) {
default:
return 0, fmt.Errorf(
"PR number in output from step with alias %q is not an int64",
cfg.PRNumberFromOpen,
cfg.PRNumberFromStep,
)
}
}
6 changes: 3 additions & 3 deletions internal/directives/git_pr_waiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ func Test_gitPRWaiter_validate(t *testing.T) {
},
},
{
name: "neither prNumber nor prNumberFromOpen specified",
name: "neither prNumber nor PRNumberFromStep specified",
config: Config{},
expectedProblems: []string{
"(root): Must validate one and only one schema",
},
},
{
name: "both prNumber and prNumberFromOpen specified",
name: "both prNumber and PRNumberFromStep specified",
config: Config{
"prNumber": 42,
"prNumberFromOpen": "fake-step",
"PRNumberFromStep": "fake-step",
},
expectedProblems: []string{
"(root): Must validate one and only one schema",
Expand Down

0 comments on commit bc4c654

Please sign in to comment.