@@ -18,13 +18,23 @@ import (
18
18
interfaces "github.com/operator-framework/api/pkg/validation/interfaces"
19
19
)
20
20
21
+ // k8sVersionKey defines the key which can be used by its consumers
22
+ // to inform what is the K8S version that should be used to do the tests against.
23
+ const k8sVersionKey = "k8s-version"
24
+
21
25
const minKubeVersionWarnMessage = "csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. " +
22
26
"Otherwise, it would mean that your operator project can be distributed and installed in any cluster version " +
23
27
"available, which is not necessarily the case for all projects."
24
28
25
29
const crdv1beta1DeprecationMsg = "apiextensions.k8s.io/v1beta1, kind=CustomResourceDefinitions was deprecated in " +
26
30
"Kubernetes v1.16 and will be removed in v1.22 in favor of v1"
27
31
32
+ // OperatorHubValidator validates the bundle manifests against the required criteria to publish
33
+ // the projects on OperatorHub.io.
34
+ //
35
+ // Note that this validator allows to receive a List of optional values as key=values. Currently, only the
36
+ // `k8s-version` key is allowed. If informed, it will perform the checks against this specific Kubernetes version where the
37
+ // operator bundle is intend to be distribute for.
28
38
var OperatorHubValidator interfaces.Validator = interfaces .ValidatorFunc (validateOperatorHub )
29
39
30
40
var validCapabilities = map [string ]struct {}{
@@ -66,7 +76,7 @@ func validateOperatorHub(objs ...interface{}) (results []errors.ManifestResult)
66
76
for _ , obj := range objs {
67
77
switch obj .(type ) {
68
78
case map [string ]string :
69
- k8sVersion = obj .(map [string ]string )["k8s" ]
79
+ k8sVersion = obj .(map [string ]string )[k8sVersionKey ]
70
80
if len (k8sVersion ) > 0 {
71
81
break
72
82
}
@@ -151,8 +161,8 @@ func validateHubChannels(channels []string) error {
151
161
// the CSV to do the checks. So, the criteria is >=minKubeVersion. By last, if the minKubeVersion is not provided
152
162
// then, we should consider the operator bundle is intend to work well in any Kubernetes version.
153
163
// Then, it means that:
154
- //--optional-values="k8s=value" flag with a value => 1.16 <= 1.22 the validator will return result as warning.
155
- //--optional-values="k8s=value" flag with a value => 1.22 the validator will return result as error.
164
+ //--optional-values="k8s-version =value" flag with a value => 1.16 <= 1.22 the validator will return result as warning.
165
+ //--optional-values="k8s-version =value" flag with a value => 1.22 the validator will return result as error.
156
166
//minKubeVersion >= 1.22 return the error result.
157
167
//minKubeVersion empty returns a warning since it would mean the same of allow install in any supported version
158
168
func validateHubDeprecatedAPIS (bundle * manifests.Bundle , versionProvided string ) (errs , warns []error ) {
0 commit comments