Skip to content

Commit 63935a4

Browse files
updated code and made state as pass and throw suggestion instead of error for missing spec in CR. (#6245) (#6266)
* updated code and made state as pass and thrown suggestions for the same Signed-off-by: laxmikantbpandhare <[email protected]> * updated code and made state as pass and thrown suggestions for the same Signed-off-by: laxmikantbpandhare <[email protected]> * updated test cases Signed-off-by: laxmikantbpandhare <[email protected]> * updated according to suggestions Signed-off-by: laxmikantbpandhare <[email protected]> * updated according to suggestions Signed-off-by: laxmikantbpandhare <[email protected]> Signed-off-by: laxmikantbpandhare <[email protected]> Signed-off-by: rashmigottipati <[email protected]> Signed-off-by: laxmikantbpandhare <[email protected]> Signed-off-by: rashmigottipati <[email protected]> Co-authored-by: Laxmikant Bhaskar Pandhare <[email protected]>
1 parent 004f995 commit 63935a4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
(scorecard): Fixes a bug where an error would be thrown if a Custom Resource did not have a `.spec` field, which is a perfectly valid scenario. Instead of throwing an error scorecard will now issue a suggestion.
6+
7+
# kind is one of:
8+
# - addition
9+
# - change
10+
# - deprecation
11+
# - removal
12+
# - bugfix
13+
kind: "bugfix"
14+
15+
# Is this a breaking change?
16+
breaking: false
17+

internal/scorecard/tests/basic.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ func checkSpec(crSet []unstructured.Unstructured,
5050
res scapiv1alpha3.TestResult) scapiv1alpha3.TestResult {
5151
for _, cr := range crSet {
5252
if cr.Object["spec"] == nil {
53-
res.Errors = append(res.Errors, fmt.Sprintf("error spec does not exist for the custom resource %s", cr.GetName()))
54-
res.State = scapiv1alpha3.FailState
53+
res.State = scapiv1alpha3.PassState
5554
res.Suggestions = append(res.Suggestions, fmt.Sprintf("spec missing from [%+v]", cr.GetName()))
5655
return res
5756
}

internal/scorecard/tests/bundle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ var _ = Describe("Basic and OLM tests", func() {
283283
},
284284
}
285285
result = checkSpec(cr, result)
286-
Expect(result.State).To(Equal(scapiv1alpha3.FailState))
286+
Expect(result.State).To(Equal(scapiv1alpha3.PassState))
287287
})
288288
It("should pass when CRs do have spec field specified", func() {
289289
cr := []unstructured.Unstructured{

0 commit comments

Comments
 (0)