99 "github.com/operator-framework/api/pkg/validation/errors"
1010 interfaces "github.com/operator-framework/api/pkg/validation/interfaces"
1111
12- "github.com/blang/semver"
1312 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1413 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1514 "k8s.io/apimachinery/pkg/runtime/schema"
@@ -33,11 +32,11 @@ func validateCSVs(objs ...interface{}) (results []errors.ManifestResult) {
3332func validateCSV (csv * v1alpha1.ClusterServiceVersion ) errors.ManifestResult {
3433 result := errors.ManifestResult {Name : csv .GetName ()}
3534 // Ensure CSV names are of the correct format.
36- if _ , _ , err := parseCSVNameFormat (csv .GetName ()); err != (errors.Error {}) {
35+ if err := parseCSVNameFormat (csv .GetName ()); err != (errors.Error {}) {
3736 result .Add (errors .ErrInvalidCSV (fmt .Sprintf ("metadata.name %s" , err ), csv .GetName ()))
3837 }
3938 if replaces := csv .Spec .Replaces ; replaces != "" {
40- if _ , _ , err := parseCSVNameFormat (replaces ); err != (errors.Error {}) {
39+ if err := parseCSVNameFormat (replaces ); err != (errors.Error {}) {
4140 result .Add (errors .ErrInvalidCSV (fmt .Sprintf ("spec.replaces %s" , err ), csv .GetName ()))
4241 }
4342 }
@@ -50,20 +49,11 @@ func validateCSV(csv *v1alpha1.ClusterServiceVersion) errors.ManifestResult {
5049 return result
5150}
5251
53- func parseCSVNameFormat (name string ) ( string , semver. Version , error ) {
52+ func parseCSVNameFormat (name string ) error {
5453 if violations := k8svalidation .IsDNS1123Subdomain (name ); len (violations ) != 0 {
55- return "" , semver. Version {}, fmt .Errorf ("%q is invalid:\n %s" , name , violations )
54+ return fmt .Errorf ("%q is invalid:\n %s" , name , violations )
5655 }
57- splitName := strings .SplitN (name , "." , 2 )
58- if len (splitName ) != 2 {
59- return "" , semver.Version {}, fmt .Errorf ("%q must have format: {operator name}.(v)X.Y.Z" , name )
60- }
61- verStr := strings .TrimLeft (splitName [1 ], "v" )
62- nameVer , err := semver .Parse (verStr )
63- if err != nil {
64- return "" , semver.Version {}, fmt .Errorf ("%q contains an invalid semver %q" , name , splitName [1 ])
65- }
66- return splitName [0 ], nameVer , errors.Error {}
56+ return errors.Error {}
6757}
6858
6959// checkFields runs checkEmptyFields and returns its errors.
0 commit comments