9
9
"github.com/operator-framework/api/pkg/validation/errors"
10
10
interfaces "github.com/operator-framework/api/pkg/validation/interfaces"
11
11
12
- "github.com/blang/semver"
13
12
"github.com/operator-framework/api/pkg/operators/v1alpha1"
14
13
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
15
14
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -33,11 +32,11 @@ func validateCSVs(objs ...interface{}) (results []errors.ManifestResult) {
33
32
func validateCSV (csv * v1alpha1.ClusterServiceVersion ) errors.ManifestResult {
34
33
result := errors.ManifestResult {Name : csv .GetName ()}
35
34
// 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 {}) {
37
36
result .Add (errors .ErrInvalidCSV (fmt .Sprintf ("metadata.name %s" , err ), csv .GetName ()))
38
37
}
39
38
if replaces := csv .Spec .Replaces ; replaces != "" {
40
- if _ , _ , err := parseCSVNameFormat (replaces ); err != (errors.Error {}) {
39
+ if err := parseCSVNameFormat (replaces ); err != (errors.Error {}) {
41
40
result .Add (errors .ErrInvalidCSV (fmt .Sprintf ("spec.replaces %s" , err ), csv .GetName ()))
42
41
}
43
42
}
@@ -50,20 +49,11 @@ func validateCSV(csv *v1alpha1.ClusterServiceVersion) errors.ManifestResult {
50
49
return result
51
50
}
52
51
53
- func parseCSVNameFormat (name string ) ( string , semver. Version , error ) {
52
+ func parseCSVNameFormat (name string ) error {
54
53
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 )
56
55
}
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 {}
67
57
}
68
58
69
59
// checkFields runs checkEmptyFields and returns its errors.
0 commit comments