Skip to content

Commit

Permalink
add WithLogLevel option
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Jul 3, 2024
1 parent 5e651e4 commit 8f5b397
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,22 @@ type runConfig struct {
ciiClient clients.CIIBestPracticesClient
projectClient packageclient.ProjectPackageClient
ossfuzzClient clients.RepoClient
checks []string
commit string
logLevel sclog.Level
checks []string
probes []string
commitDepth int
}

type Option func(*runConfig) error

func WithLogLevel(level sclog.Level) Option {
return func(c *runConfig) error {
c.logLevel = level
return nil
}
}

func WithCommitDepth(depth int) Option {
return func(c *runConfig) error {
c.commitDepth = depth
Expand Down Expand Up @@ -366,16 +374,16 @@ func WithOpenSSFBestPraticesClient(client clients.CIIBestPracticesClient) Option
}

func Run(ctx context.Context, repo clients.Repo, opts ...Option) (ScorecardResult, error) {
// TODO logger
logger := sclog.NewLogger(sclog.InfoLevel)
c := runConfig{
commit: clients.HeadSHA,
commit: clients.HeadSHA,
logLevel: sclog.DefaultLevel,
}
for _, option := range opts {
if err := option(&c); err != nil {
return ScorecardResult{}, err
}
}
logger := sclog.NewLogger(c.logLevel)
if c.ciiClient == nil {
c.ciiClient = clients.DefaultCIIBestPracticesClient()
}
Expand Down

0 comments on commit 8f5b397

Please sign in to comment.