Skip to content

Commit

Permalink
checker: Add NewRunner constructor for Runner
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <[email protected]>
  • Loading branch information
justaugustus committed Feb 16, 2022
1 parent c80a8f2 commit 29f9cd8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
20 changes: 20 additions & 0 deletions checker/check_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ type Runner struct {
CheckRequest CheckRequest
}

func NewRunner(checkName, repo string, checkReq CheckRequest) *Runner {
return &Runner{
CheckName: checkName,
Repo: repo,
CheckRequest: checkReq,
}
}

func (r *Runner) WithCheckName(check string) {
r.CheckName = check
}

func (r *Runner) WithRepo(repo string) {
r.Repo = repo
}

func (r *Runner) WithCheckRequest(checkReq CheckRequest) {
r.CheckRequest = checkReq
}

// CheckFn defined for convenience.
type CheckFn func(*CheckRequest) CheckResult

Expand Down
11 changes: 6 additions & 5 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ func runEnabledChecks(ctx context.Context,
wg.Add(1)
go func() {
defer wg.Done()
runner := checker.Runner{
Repo: repo.URI(),
CheckName: checkName,
CheckRequest: request,
}
runner := checker.NewRunner(
checkName,
repo.URI(),
request,
)

resultsCh <- runner.Run(ctx, checkFn)
}()
}
Expand Down

0 comments on commit 29f9cd8

Please sign in to comment.