@@ -21,6 +21,7 @@ import (
21
21
//
22
22
// - The channel names seems are not following the convention https://olm.operatorframework.io/docs/best-practices/channel-naming/
23
23
//
24
+ // - CRDs defined in the bundle have empty descriptions
24
25
var GoodPracticesValidator interfaces.Validator = interfaces .ValidatorFunc (goodPracticesValidator )
25
26
26
27
func goodPracticesValidator (objs ... interface {}) (results []errors.ManifestResult ) {
@@ -48,20 +49,20 @@ func validateGoodPracticesFrom(bundle *manifests.Bundle) errors.ManifestResult {
48
49
}
49
50
50
51
errs , warns := validateResourceRequests (bundle .CSV )
52
+ warns = append (warns , validateCrdDescriptions (bundle .CSV .Spec .CustomResourceDefinitions )... )
53
+ warns = append (warns , validateHubChannels (bundle ))
54
+
51
55
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
+ }
53
59
}
54
60
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
+ }
59
64
}
60
65
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
- }
65
66
return result
66
67
}
67
68
@@ -90,7 +91,8 @@ func validateResourceRequests(csv *operatorsv1alpha1.ClusterServiceVersion) (err
90
91
// validateHubChannels will check the channels. The motivation for the following check is to ensure that operators
91
92
// authors knows if their operator bundles are or not respecting the Naming Convention Rules.
92
93
// 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 )
94
96
const candidate = "candidate"
95
97
const stable = "stable"
96
98
const fast = "fast"
@@ -130,7 +132,7 @@ func getUniqueValues(array []string) []string {
130
132
return result
131
133
}
132
134
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.
134
136
func validateCrdDescriptions (crds operatorsv1alpha1.CustomResourceDefinitions ) []error {
135
137
f := func (crds []operatorsv1alpha1.CRDDescription , relation string ) []error {
136
138
errors := make ([]error , 0 , len (crds ))
0 commit comments