Skip to content

Commit ae7fab6

Browse files
author
Eric Stroczynski
authored
internal/pkg/scorecard/plugins: return an error if no CRs exist in alm-examples (#1789)
* internal/pkg/scorecard/plugins: return an error if no CRs exist in alm-examples without cr-manifest set * CHANGELOG.md: add bug fix line
1 parent d351dd8 commit ae7fab6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
### Bug Fixes
1818

19+
- Check if `metadata.annotations['alm-examples']` is non-empty before creating contained CR manifests in the scorecard. ([#1789](https://github.com/operator-framework/operator-sdk/pull/1789))
20+
1921
## v0.9.0
2022

2123
### Added

internal/pkg/scorecard/plugins/plugin_runner.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ func RunInternalPlugin(plugin PluginType, config *viper.Viper, logFile io.ReadWr
159159
if crJSONStr, ok := csv.ObjectMeta.Annotations["alm-examples"]; ok {
160160
var crs []interface{}
161161
if err = json.Unmarshal([]byte(crJSONStr), &crs); err != nil {
162-
return scapiv1alpha1.ScorecardOutput{}, err
162+
return scapiv1alpha1.ScorecardOutput{}, errors.Wrapf(err, "metadata.annotations['alm-examples'] in CSV %s incorrectly formatted", csv.GetName())
163+
}
164+
if len(crs) == 0 {
165+
return scapiv1alpha1.ScorecardOutput{}, errors.Errorf("no CRs found in metadata.annotations['alm-examples'] in CSV %s and cr-manifest config option not set", csv.GetName())
163166
}
164167
// TODO: run scorecard against all CR's in CSV.
165168
cr := crs[0]

0 commit comments

Comments
 (0)