@@ -21,6 +21,7 @@ import (
2121//
2222// - The channel names seems are not following the convention https://olm.operatorframework.io/docs/best-practices/channel-naming/
2323//
24+ // - CRDs defined in the bundle have empty descriptions
2425var GoodPracticesValidator interfaces.Validator = interfaces .ValidatorFunc (goodPracticesValidator )
2526
2627func goodPracticesValidator (objs ... interface {}) (results []errors.ManifestResult ) {
@@ -48,20 +49,20 @@ func validateGoodPracticesFrom(bundle *manifests.Bundle) errors.ManifestResult {
4849 }
4950
5051 errs , warns := validateResourceRequests (bundle .CSV )
52+ warns = append (warns , validateCrdDescriptions (bundle .CSV .Spec .CustomResourceDefinitions )... )
53+ warns = append (warns , validateHubChannels (bundle ))
54+
5155 for _ , err := range errs {
52- result .Add (errors .ErrFailedValidation (err .Error (), bundle .CSV .GetName ()))
56+ if err != nil {
57+ result .Add (errors .ErrFailedValidation (err .Error (), bundle .CSV .GetName ()))
58+ }
5359 }
5460 for _ , warn := range warns {
55- result .Add (errors .WarnFailedValidation (warn .Error (), bundle .CSV .GetName ()))
56- }
57- for _ , warn := range validateCrdDescriptions (bundle .CSV .Spec .CustomResourceDefinitions ) {
58- result .Add (errors .WarnFailedValidation (warn .Error (), bundle .CSV .GetName ()))
61+ if warn != nil {
62+ result .Add (errors .WarnFailedValidation (warn .Error (), bundle .CSV .GetName ()))
63+ }
5964 }
6065
61- channels := append (bundle .Channels , bundle .DefaultChannel )
62- if warn := validateHubChannels (channels ); warn != nil {
63- result .Add (errors .WarnFailedValidation (warn .Error (), bundle .CSV .GetName ()))
64- }
6566 return result
6667}
6768
@@ -90,7 +91,8 @@ func validateResourceRequests(csv *operatorsv1alpha1.ClusterServiceVersion) (err
9091// validateHubChannels will check the channels. The motivation for the following check is to ensure that operators
9192// authors knows if their operator bundles are or not respecting the Naming Convention Rules.
9293// However, the operator authors still able to choose the names as please them.
93- func validateHubChannels (channels []string ) error {
94+ func validateHubChannels (bundle * manifests.Bundle ) error {
95+ channels := append (bundle .Channels , bundle .DefaultChannel )
9496 const candidate = "candidate"
9597 const stable = "stable"
9698 const fast = "fast"
@@ -130,7 +132,7 @@ func getUniqueValues(array []string) []string {
130132 return result
131133}
132134
133- // validateCrdDescrptions ensures that all CRDs defined in the bundle have non-empty descriptions.
135+ // validateCrdDescriptions ensures that all CRDs defined in the bundle have non-empty descriptions.
134136func validateCrdDescriptions (crds operatorsv1alpha1.CustomResourceDefinitions ) []error {
135137 f := func (crds []operatorsv1alpha1.CRDDescription , relation string ) []error {
136138 errors := make ([]error , 0 , len (crds ))
0 commit comments