File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ func hasStrictAnalyzer(analyzerMap map[string]interface{}) (bool, error) {
6464 if err != nil {
6565 return false , errors .Wrap (err , "error while un-marshalling marshalledAnalyzers" )
6666 }
67+ if analyzeMeta .Exclude .BoolOrDefaultFalse () {
68+ continue
69+ }
6770 if analyzeMeta .Strict .BoolOrDefaultFalse () {
6871 return true , nil
6972 }
Original file line number Diff line number Diff line change 4646 StrVal : "1" ,
4747 },
4848 }
49+ analyzeMetaStrictTrueExcludeTrue = troubleshootv1beta2.AnalyzeMeta {
50+ Exclude : & multitype.BoolOrString {
51+ Type : multitype .Bool ,
52+ BoolVal : true ,
53+ },
54+ Strict : & multitype.BoolOrString {
55+ Type : multitype .Bool ,
56+ BoolVal : true ,
57+ },
58+ }
4959)
5060
5161func TestHasStrictAnalyzers (t * testing.T ) {
@@ -238,6 +248,36 @@ func TestHasStrictAnalyzers(t *testing.T) {
238248 want : true ,
239249 wantErr : false ,
240250 },
251+ {
252+ name : "expect false when preflight spec's analyzer has analyzer with strict true and exclude true" ,
253+ preflight : & troubleshootv1beta2.Preflight {
254+ Spec : troubleshootv1beta2.PreflightSpec {
255+ Analyzers : []* troubleshootv1beta2.Analyze {
256+ {
257+ ClusterVersion : & troubleshootv1beta2.ClusterVersion {AnalyzeMeta : analyzeMetaStrictTrueExcludeTrue },
258+ },
259+ },
260+ },
261+ },
262+ want : false ,
263+ wantErr : false ,
264+ },
265+ {
266+ name : "expect true when preflight spec's analyzer has analyzer with strict true in one of multiple analyzers, but one analyzer with strict true is exclude true" ,
267+ preflight : & troubleshootv1beta2.Preflight {
268+ Spec : troubleshootv1beta2.PreflightSpec {
269+ Analyzers : []* troubleshootv1beta2.Analyze {
270+ {
271+ ClusterVersion : & troubleshootv1beta2.ClusterVersion {AnalyzeMeta : analyzeMetaStrictTrueExcludeTrue },
272+ StorageClass : & troubleshootv1beta2.StorageClass {AnalyzeMeta : analyzeMetaStrictFalseInt },
273+ Secret : & troubleshootv1beta2.AnalyzeSecret {AnalyzeMeta : analyzeMetaStrictTrueBool },
274+ },
275+ },
276+ },
277+ },
278+ want : true ,
279+ wantErr : false ,
280+ },
241281 }
242282 for _ , tt := range tests {
243283 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments