@@ -239,75 +239,71 @@ func validateImageFile(checks CommunityOperatorChecks, deprecatedAPImsg string)
239
239
}
240
240
241
241
value := strings .Split (line [i ], "=" )
242
- indexRange := value [1 ]
243
- doubleCote := "\" "
244
- singleCote := "'"
245
- indexRange = strings .ReplaceAll (indexRange , singleCote , "" )
246
- indexRange = strings .ReplaceAll (indexRange , doubleCote , "" )
242
+ // It means that the OCP label is =OCP version
243
+ if len (value ) > 2 && len (value [2 ]) > 0 {
244
+ version := cleanStringToGetTheVersionToParse (value [2 ])
245
+ verParsed , err := semver .ParseTolerant (version )
246
+ if err != nil {
247
+ checks .errs = append (checks .errs , fmt .Errorf ("unable to parse the value (%s) on (%s)" ,
248
+ version , ocpLabelindex ))
249
+ return checks
250
+ }
251
+
252
+ if verParsed .GE (semVerOCPV1beta1Unsupported ) {
253
+ checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
254
+ "deprecated and removed in v1.22. " +
255
+ "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22. " +
256
+ "Migrate the API(s) for " +
257
+ "%s or provide compatible version(s) by using the %s annotation in " +
258
+ "`metadata/annotations.yaml` to ensure that the index image will be geneared " +
259
+ "with its label. (e.g. LABEL %s='4.6-4.8')" ,
260
+ deprecatedAPImsg ,
261
+ ocpLabelindex ,
262
+ ocpLabelindex ))
263
+ return checks
264
+ }
265
+ return checks
266
+ }
267
+ indexRange := cleanStringToGetTheVersionToParse (value [1 ])
247
268
if len (indexRange ) > 1 {
248
269
// if has the = then, the value needs to be < 4.9
249
- if strings .Contains (indexRange , "=" ) {
250
- version := strings .Split (indexRange , "=" )[1 ]
251
- verParsed , err := semver .ParseTolerant (version )
252
- if err != nil {
253
- checks .errs = append (checks .errs , fmt .Errorf ("unable to parse the value (%s) on (%s)" ,
254
- version , ocpLabelindex ))
255
- return checks
256
- }
257
-
258
- if verParsed .GE (semVerOCPV1beta1Unsupported ) {
259
- checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
260
- "deprecated and removed in v1.22. " +
261
- "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22. " +
262
- "Migrate the API(s) for " +
263
- "%s or provide compatible version(s) by using the %s annotation in " +
264
- "`metadata/annotations.yaml` to ensure that the index image will be geneared " +
265
- "with its label. (e.g. LABEL %s='4.6-4.8')" ,
266
- deprecatedAPImsg ,
267
- ocpLabelindex ,
268
- ocpLabelindex ))
269
- return checks
270
- }
271
- } else {
272
- // if not has not the = then the value needs contains - value less < 4.9
273
- if ! strings .Contains (indexRange , "-" ) {
274
- checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
275
- "deprecated and removed in v1.22. " +
276
- "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22 " +
277
- "The %s allows to distribute it on >= %s. Migrate the API(s) for " +
278
- "%s or provide compatible version(s) by using the %s annotation in " +
279
- "`metadata/annotations.yaml` to ensure that the index image will be generated " +
280
- "with its label. (e.g. LABEL %s='4.6-4.8')" ,
281
- indexRange ,
282
- ocpVerV1beta1Unsupported ,
283
- deprecatedAPImsg ,
284
- ocpLabelindex ,
285
- ocpLabelindex ))
286
- return checks
287
- }
288
-
289
- version := strings .Split (indexRange , "-" )[1 ]
290
- verParsed , err := semver .ParseTolerant (version )
291
- if err != nil {
292
- checks .errs = append (checks .errs , fmt .Errorf ("unable to parse the value (%s) on (%s)" ,
293
- version , ocpLabelindex ))
294
- return checks
295
- }
296
-
297
- if verParsed .GE (semVerOCPV1beta1Unsupported ) {
298
- checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
299
- "deprecated and removed in v1.22. " +
300
- "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22. " +
301
- "Upgrade the APIs from " +
302
- "for %s or provide compatible distribution version(s) by using the %s " +
303
- "annotation in `metadata/annotations.yaml` to ensure that the index image will " +
304
- "be generated with its label. (e.g. LABEL %s='4.6-4.8')" ,
305
- deprecatedAPImsg ,
306
- ocpLabelindex ,
307
- ocpLabelindex ))
308
- return checks
309
- }
270
+ // if not has not the = then the value needs contains - value less < 4.9
271
+ if ! strings .Contains (indexRange , "-" ) {
272
+ checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
273
+ "deprecated and removed in v1.22. " +
274
+ "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22 " +
275
+ "The %s allows to distribute it on >= %s. Migrate the API(s) for " +
276
+ "%s or provide compatible version(s) by using the %s annotation in " +
277
+ "`metadata/annotations.yaml` to ensure that the index image will be generated " +
278
+ "with its label. (e.g. LABEL %s='4.6-4.8')" ,
279
+ indexRange ,
280
+ ocpVerV1beta1Unsupported ,
281
+ deprecatedAPImsg ,
282
+ ocpLabelindex ,
283
+ ocpLabelindex ))
284
+ return checks
285
+ }
286
+
287
+ version := strings .Split (indexRange , "-" )[1 ]
288
+ verParsed , err := semver .ParseTolerant (version )
289
+ if err != nil {
290
+ checks .errs = append (checks .errs , fmt .Errorf ("unable to parse the value (%s) on (%s)" ,
291
+ version , ocpLabelindex ))
292
+ return checks
293
+ }
310
294
295
+ if verParsed .GE (semVerOCPV1beta1Unsupported ) {
296
+ checks .errs = append (checks .errs , fmt .Errorf ("this bundle is using APIs which were " +
297
+ "deprecated and removed in v1.22. " +
298
+ "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22. " +
299
+ "Upgrade the APIs from " +
300
+ "for %s or provide compatible distribution version(s) by using the %s " +
301
+ "annotation in `metadata/annotations.yaml` to ensure that the index image will " +
302
+ "be generated with its label. (e.g. LABEL %s='4.6-4.8')" ,
303
+ deprecatedAPImsg ,
304
+ ocpLabelindex ,
305
+ ocpLabelindex ))
306
+ return checks
311
307
}
312
308
} else {
313
309
checks .errs = append (checks .errs , fmt .Errorf ("unable to get the range informed on %s" ,
@@ -328,3 +324,14 @@ func validateImageFile(checks CommunityOperatorChecks, deprecatedAPImsg string)
328
324
}
329
325
return checks
330
326
}
327
+
328
+ // cleanStringToGetTheVersionToParse will remove the expected characters for
329
+ // we are able to parse the version informed.
330
+ func cleanStringToGetTheVersionToParse (value string ) string {
331
+ doubleQuote := "\" "
332
+ singleQuote := "'"
333
+ value = strings .ReplaceAll (value , singleQuote , "" )
334
+ value = strings .ReplaceAll (value , doubleQuote , "" )
335
+ value = strings .ReplaceAll (value , "v" , "" )
336
+ return value
337
+ }
0 commit comments