From 3fda0632c649cfe24b6c52c14220ec6042672b54 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 2 Oct 2021 10:17:04 +0100 Subject: [PATCH] Add information to the errors raised by scorecard basic tests to allow easily identify the scenarios Signed-off-by: Camila Macedo --- changelog/fragments/msg_scorecard.yaml | 13 +++++++++++++ internal/scorecard/tests/basic.go | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changelog/fragments/msg_scorecard.yaml diff --git a/changelog/fragments/msg_scorecard.yaml b/changelog/fragments/msg_scorecard.yaml new file mode 100644 index 00000000000..094a4f2e62a --- /dev/null +++ b/changelog/fragments/msg_scorecard.yaml @@ -0,0 +1,13 @@ +# entries is a list of entries to include in +# release notes and/or the migration guide +entries: + - description: > + Add information to the errors raised by scorecard basic tests to allow easily identify the scenarios + + # kind is one of: + # - addition + # - change + # - deprecation + # - removal + # - bugfix + kind: "addition" diff --git a/internal/scorecard/tests/basic.go b/internal/scorecard/tests/basic.go index d5e9bf12ac5..3948f08fdf6 100644 --- a/internal/scorecard/tests/basic.go +++ b/internal/scorecard/tests/basic.go @@ -15,6 +15,8 @@ package tests import ( + "fmt" + scapiv1alpha3 "github.com/operator-framework/api/pkg/apis/scorecard/v1alpha3" apimanifests "github.com/operator-framework/api/pkg/manifests" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -35,7 +37,7 @@ func CheckSpecTest(bundle *apimanifests.Bundle) scapiv1alpha3.TestStatus { crSet, err := GetCRs(bundle) if err != nil { - r.Errors = append(r.Errors, "error getting custom resources") + r.Errors = append(r.Errors, fmt.Sprintf("error getting custom resources: %s", err)) r.State = scapiv1alpha3.FailState } @@ -48,7 +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, "error spec does not exist") + res.Errors = append(res.Errors, fmt.Sprintf("error spec does not exist for the custom resource %s", cr.GetName())) res.State = scapiv1alpha3.FailState return res }