Skip to content

Commit fed0e73

Browse files
Add information to the errors raised by scorecard basic tests to allow easily identify the scenarios (#5273)
Signed-off-by: Camila Macedo <[email protected]>
1 parent e8a5d31 commit fed0e73

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# entries is a list of entries to include in
2+
# release notes and/or the migration guide
3+
entries:
4+
- description: >
5+
Add information to the errors raised by scorecard basic tests to allow easily identify the scenarios
6+
7+
# kind is one of:
8+
# - addition
9+
# - change
10+
# - deprecation
11+
# - removal
12+
# - bugfix
13+
kind: "addition"

internal/scorecard/tests/basic.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package tests
1616

1717
import (
18+
"fmt"
19+
1820
scapiv1alpha3 "github.com/operator-framework/api/pkg/apis/scorecard/v1alpha3"
1921
apimanifests "github.com/operator-framework/api/pkg/manifests"
2022
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -35,7 +37,7 @@ func CheckSpecTest(bundle *apimanifests.Bundle) scapiv1alpha3.TestStatus {
3537

3638
crSet, err := GetCRs(bundle)
3739
if err != nil {
38-
r.Errors = append(r.Errors, "error getting custom resources")
40+
r.Errors = append(r.Errors, fmt.Sprintf("error getting custom resources: %s", err))
3941
r.State = scapiv1alpha3.FailState
4042
}
4143

@@ -48,7 +50,7 @@ func checkSpec(crSet []unstructured.Unstructured,
4850
res scapiv1alpha3.TestResult) scapiv1alpha3.TestResult {
4951
for _, cr := range crSet {
5052
if cr.Object["spec"] == nil {
51-
res.Errors = append(res.Errors, "error spec does not exist")
53+
res.Errors = append(res.Errors, fmt.Sprintf("error spec does not exist for the custom resource %s", cr.GetName()))
5254
res.State = scapiv1alpha3.FailState
5355
return res
5456
}

0 commit comments

Comments
 (0)