@@ -18,13 +18,23 @@ import (
1818 interfaces "github.com/operator-framework/api/pkg/validation/interfaces"
1919)
2020
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+
2125const minKubeVersionWarnMessage = "csv.Spec.minKubeVersion is not informed. It is recommended you provide this information. " +
2226 "Otherwise, it would mean that your operator project can be distributed and installed in any cluster version " +
2327 "available, which is not necessarily the case for all projects."
2428
2529const crdv1beta1DeprecationMsg = "apiextensions.k8s.io/v1beta1, kind=CustomResourceDefinitions was deprecated in " +
2630 "Kubernetes v1.16 and will be removed in v1.22 in favor of v1"
2731
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.
2838var OperatorHubValidator interfaces.Validator = interfaces .ValidatorFunc (validateOperatorHub )
2939
3040var validCapabilities = map [string ]struct {}{
@@ -66,7 +76,7 @@ func validateOperatorHub(objs ...interface{}) (results []errors.ManifestResult)
6676 for _ , obj := range objs {
6777 switch obj .(type ) {
6878 case map [string ]string :
69- k8sVersion = obj .(map [string ]string )["k8s" ]
79+ k8sVersion = obj .(map [string ]string )[k8sVersionKey ]
7080 if len (k8sVersion ) > 0 {
7181 break
7282 }
@@ -151,8 +161,8 @@ func validateHubChannels(channels []string) error {
151161// the CSV to do the checks. So, the criteria is >=minKubeVersion. By last, if the minKubeVersion is not provided
152162// then, we should consider the operator bundle is intend to work well in any Kubernetes version.
153163// 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.
156166//minKubeVersion >= 1.22 return the error result.
157167//minKubeVersion empty returns a warning since it would mean the same of allow install in any supported version
158168func validateHubDeprecatedAPIS (bundle * manifests.Bundle , versionProvided string ) (errs , warns []error ) {
0 commit comments