-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a minimal status option to the report generating command #418
Add a minimal status option to the report generating command #418
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -125,6 +125,26 @@ func (r *Report) WriteToFile(filePath string) error { | |||
return os.WriteFile(filePath, data, 0600) | |||
} | |||
|
|||
// SetMinStatus sets minStatus of the report. It also removes all checks with status less than the specified one. | |||
// If the new minStatus is less that the original one, nothing is changed. | |||
func (r *Report) SetMinStatus(minStatus rule.Status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we implement this as a report option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can disregard my comment. I see that we already have this and you are making use of it.
cmd/diki/app/app.go
Outdated
@@ -144,6 +146,7 @@ func addRunFlags(cmd *cobra.Command, opts *runOptions) { | |||
func addReportGenerateFlags(cmd *cobra.Command, opts *generateOptions) { | |||
cmd.PersistentFlags().Var(cliflag.NewMapStringString(&opts.distinctBy), "distinct-by", "If set generates a merged report. The keys are the IDs for the providers which the merged report will include and the values are distinct metadata attributes to be used as IDs for the different reports.") | |||
cmd.PersistentFlags().StringVar(&opts.format, "format", "html", "Format for the output report. Format can be one of 'html' or 'json'.") | |||
cmd.PersistentFlags().StringVar(&opts.minStatus, "min-status", "Passed", "If set specifies the minimal status that will be included in the generated report. Status can be one of 'Passed', 'Skipped', 'Accepted', 'Warning', 'Failed', 'Errored' or 'NotImplemented'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention the statuses in a sorted order stating which is the highest
pkg/report/report.go
Outdated
@@ -125,6 +125,26 @@ func (r *Report) WriteToFile(filePath string) error { | |||
return os.WriteFile(filePath, data, 0600) | |||
} | |||
|
|||
// SetMinStatus sets minStatus of the report. It also removes all checks with status less than the specified one. | |||
// If the new minStatus is less that the original one, nothing is changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If the new minStatus is less that the original one, nothing is changed. | |
// If the new minStatus is less than the original one, nothing is changed. |
@@ -125,6 +125,26 @@ func (r *Report) WriteToFile(filePath string) error { | |||
return os.WriteFile(filePath, data, 0600) | |||
} | |||
|
|||
// SetMinStatus sets minStatus of the report. It also removes all checks with status less than the specified one. | |||
// If the new minStatus is less that the original one, nothing is changed. | |||
func (r *Report) SetMinStatus(minStatus rule.Status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can disregard my comment. I see that we already have this and you are making use of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What this PR does / why we need it:
This PR adds an additional flag to the diki report generate command that specifies the minimal status of the checks that should be included in the rendered report. This flag only discards check results that have a higher status when generating a regular or merged report.
Which issue(s) this PR fixes:
Fixes #378
Special notes for your reviewer:
Release note: