Skip to content

Commit 319a3a8

Browse files
authored
Merge pull request #596 from replicatedhq/kiraboyle/sc-49361/strict-preflight-is-still-being-enforced
do not return that a strict analyzer is present in an application if …
2 parents 3a5816c + 5e7bd06 commit 319a3a8

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

pkg/preflight/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

pkg/preflight/util_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ var (
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

5161
func 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) {

0 commit comments

Comments
 (0)