Skip to content
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

updated code and made state as pass and throw suggestion instead of error for missing spec in CR. #6245

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions changelog/fragments/spec-scoreacrd-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
(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.

# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "bugfix"

# Is this a breaking change?
breaking: false

3 changes: 1 addition & 2 deletions internal/scorecard/tests/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func checkSpec(crSet []unstructured.Unstructured,
res scapiv1alpha3.TestResult) scapiv1alpha3.TestResult {
for _, cr := range crSet {
if cr.Object["spec"] == nil {
res.Errors = append(res.Errors, fmt.Sprintf("error spec does not exist for the custom resource %s", cr.GetName()))
res.State = scapiv1alpha3.FailState
res.State = scapiv1alpha3.PassState
res.Suggestions = append(res.Suggestions, fmt.Sprintf("spec missing from [%+v]", cr.GetName()))
laxmikantbpandhare marked this conversation as resolved.
Show resolved Hide resolved
return res
}
Expand Down
2 changes: 1 addition & 1 deletion internal/scorecard/tests/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ var _ = Describe("Basic and OLM tests", func() {
},
}
result = checkSpec(cr, result)
Expect(result.State).To(Equal(scapiv1alpha3.FailState))
Expect(result.State).To(Equal(scapiv1alpha3.PassState))
})
It("should pass when CRs do have spec field specified", func() {
cr := []unstructured.Unstructured{
Expand Down