Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ef7cf2

Browse files
committed
Add support for report file option
When a report file path is specified by the user, a JSON formatted report of the checks will be written to that path.
1 parent 703fa3d commit 7ef7cf2

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

‎configuration/configuration.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func Initialize() {
2727
// superprojectType = projecttype.All
2828

2929
outputFormat = "text"
30+
//reportFilePath = paths.New("report.json")
3031

3132
feedback.SetFormat(feedback.JSON)
3233
logrus.SetLevel(logrus.PanicLevel)
@@ -66,6 +67,13 @@ func OutputFormat() string {
6667
return outputFormat
6768
}
6869

70+
var reportFilePath *paths.Path
71+
72+
// ReportFilePath returns the path to save the report file at.
73+
func ReportFilePath() *paths.Path {
74+
return reportFilePath
75+
}
76+
6977
var targetPath *paths.Path
7078

7179
// TargetPath returns the projects search path.

‎main.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ func main() {
4040
fmt.Println(result.JSONReport())
4141
}
4242

43+
if configuration.ReportFilePath() != nil {
44+
// Write report file.
45+
result.WriteReport()
46+
}
47+
4348
if !result.Passed() {
4449
os.Exit(errorcodes.ErrGeneric)
4550
}

‎result/result.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ func jsonReportRaw() []byte {
207207
return reportJSON
208208
}
209209

210+
// WriteReport writes a report for all projects to the specified file.
211+
func WriteReport() {
212+
// Write report file
213+
err := configuration.ReportFilePath().WriteFile(jsonReportRaw())
214+
if err != nil {
215+
feedback.Errorf("Error while writing report: %v", err)
216+
os.Exit(errorcodes.ErrGeneric)
217+
}
218+
}
219+
210220
// Passed returns whether the checks passed cumulatively.
211221
func Passed() bool {
212222
return report.Summary.Pass

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /