Skip to content

Commit

Permalink
AsStatementResultOption
Browse files Browse the repository at this point in the history
This adds an options set for the intoto statement output.
It just wraps the json2 options for now.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
  • Loading branch information
puerco committed Jan 17, 2025
1 parent 0d3402c commit a43c588
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/scorecard/scorecard_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ func FormatResults(
}
err = results.AsJSON2(output, doc, o)
case options.FormatStatement:
o := &AsJSON2ResultOption{
Details: opts.ShowDetails,
Annotations: opts.ShowAnnotations,
LogLevel: log.ParseLevel(opts.LogLevel),
o := &AsStatementResultOption{
AsJSON2ResultOption: AsJSON2ResultOption{
Details: opts.ShowDetails,
Annotations: opts.ShowAnnotations,
LogLevel: log.ParseLevel(opts.LogLevel),
},
}
err = results.AsStatement(output, doc, o)
case options.FormatProbe:
Expand Down
9 changes: 7 additions & 2 deletions pkg/scorecard/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ type Predicate struct {
JSONScorecardResultV2
}

// AsStatementResultOption wraps AsJSON2ResultOption preparing it for

Check failure on line 43 in pkg/scorecard/statement.go

View workflow job for this annotation

GitHub Actions / check-linter

Comment should end in a period (godot)
type AsStatementResultOption struct {
AsJSON2ResultOption
}

// AsStatement converts the results as an in-toto statement.
func (r *Result) AsStatement(writer io.Writer, checkDocs docs.Doc, opt *AsJSON2ResultOption) error {
func (r *Result) AsStatement(writer io.Writer, checkDocs docs.Doc, opt *AsStatementResultOption) error {
// Build the attestation subject from the result Repo.
subject := intoto.ResourceDescriptor{
Name: r.Repo.Name,
Expand All @@ -51,7 +56,7 @@ func (r *Result) AsStatement(writer io.Writer, checkDocs docs.Doc, opt *AsJSON2R
},
}

json2, err := r.resultsToJSON2(checkDocs, opt)
json2, err := r.resultsToJSON2(checkDocs, &opt.AsJSON2ResultOption)
if err != nil {
return sce.WithMessage(sce.ErrScorecardInternal, err.Error())
}
Expand Down

0 comments on commit a43c588

Please sign in to comment.