@@ -6,9 +6,11 @@ package cmd
6
6
import (
7
7
"errors"
8
8
html_report "github.com/daveshanley/vacuum/html-report"
9
+ "fmt"
9
10
"github.com/daveshanley/vacuum/model"
10
11
"github.com/daveshanley/vacuum/model/reports"
11
12
"github.com/daveshanley/vacuum/motor"
13
+ "gopkg.in/yaml.v3"
12
14
"github.com/daveshanley/vacuum/statistics"
13
15
"github.com/daveshanley/vacuum/utils"
14
16
vacuum_report "github.com/daveshanley/vacuum/vacuum-report"
@@ -49,6 +51,7 @@ func GetHTMLReportCommand() *cobra.Command {
49
51
hardModeFlag , _ := cmd .Flags ().GetBool ("hard-mode" )
50
52
silent , _ := cmd .Flags ().GetBool ("silent" )
51
53
remoteFlag , _ := cmd .Flags ().GetBool ("remote" )
54
+ ignoreFile , _ := cmd .Flags ().GetString ("ignore-file" )
52
55
53
56
// disable color and styling, for CI/CD use.
54
57
// https://github.com/daveshanley/vacuum/issues/234
@@ -90,6 +93,18 @@ func GetHTMLReportCommand() *cobra.Command {
90
93
var specInfo * datamodel.SpecInfo
91
94
var stats * reports.ReportStatistics
92
95
96
+ ignoredItems := model.IgnoredItems {}
97
+ if ignoreFile != "" {
98
+ raw , ferr := os .ReadFile (ignoreFile )
99
+ if ferr != nil {
100
+ return fmt .Errorf ("failed to read ignore file: %w" , ferr )
101
+ }
102
+ ferr = yaml .Unmarshal (raw , & ignoredItems )
103
+ if ferr != nil {
104
+ return fmt .Errorf ("failed to parse ignore file: %w" , ferr )
105
+ }
106
+ }
107
+
93
108
// if we have a pre-compiled report, jump straight to the end and collect $500
94
109
if vacuumReport == nil {
95
110
@@ -110,7 +125,7 @@ func GetHTMLReportCommand() *cobra.Command {
110
125
KeyFile : keyFile ,
111
126
CAFile : caFile ,
112
127
Insecure : insecure ,
113
- })
128
+ }, ignoredItems )
114
129
if err != nil {
115
130
pterm .Error .Printf ("Failed to generate report: %v\n \n " , err )
116
131
return err
@@ -124,6 +139,8 @@ func GetHTMLReportCommand() *cobra.Command {
124
139
} else {
125
140
126
141
resultSet = model .NewRuleResultSetPointer (vacuumReport .ResultSet .Results )
142
+ // Apply ignore filter to pre-compiled report results
143
+ resultSet .Results = utils .FilterIgnoredResultsPtr (resultSet .Results , ignoredItems )
127
144
specInfo = vacuumReport .SpecInfo
128
145
stats = vacuumReport .Statistics
129
146
specInfo .Generated = vacuumReport .Generated
@@ -156,6 +173,7 @@ func GetHTMLReportCommand() *cobra.Command {
156
173
}
157
174
cmd .Flags ().BoolP ("disableTimestamp" , "d" , false , "Disable timestamp in report" )
158
175
cmd .Flags ().BoolP ("no-style" , "q" , false , "Disable styling and color output, just plain text (useful for CI/CD)" )
176
+ cmd .Flags ().String ("ignore-file" , "" , "Path to ignore file" )
159
177
160
178
return cmd
161
179
}
0 commit comments