Skip to content

Commit a10365d

Browse files
authored
operator: add redhat-operators organizacion check in the catalog (#82)
1 parent fc1d120 commit a10365d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

pkg/certdb/onlinecheck/onlinecheck.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
// Here we are using only External endpoint to collect published containers and operator information
3737

3838
const filterCertifiedOperatorsOrg = "organization==certified-operators"
39+
const filterRedHatOperatorsOrg = "organization==redhat-operators"
3940
const certifiedOperatorsCatalogURL = "https://catalog.redhat.com/api/containers/v1/operators/bundles?page_size=100&page=0&filter=csv_name==%s;%s"
4041
const certifiedContainerCatalogURL = "https://catalog.redhat.com/api/containers/v1/repositories/registry/%s/repository/%s/images?"
4142
const certifiedContainerCatalogDigestURL = "https://catalog.redhat.com/api/containers/v1/images?filter=image_id==%s"
@@ -218,21 +219,26 @@ func (validator OnlineValidator) IsOperatorCertified(csvName, ocpVersion, channe
218219
_, operatorVersion := offlinecheck.ExtractNameVersionFromName(csvName)
219220
var responseData []byte
220221
var err error
221-
url := fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterCertifiedOperatorsOrg)
222-
log.Trace(url)
223-
if responseData, err = validator.GetRequest(url); err != nil || len(responseData) == 0 {
224-
return false
225-
}
226-
operatorEntries := offlinecheck.OperatorCatalog{}
227-
err = json.Unmarshal(responseData, &operatorEntries)
228-
if err != nil {
229-
log.Error("Cannot marshall binary data", err)
230-
return false
222+
catalogUrls := []string{
223+
fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterCertifiedOperatorsOrg),
224+
fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterRedHatOperatorsOrg),
231225
}
232-
for _, operator := range operatorEntries.Data {
233-
_, opVersion := offlinecheck.ExtractNameVersionFromName(operator.CsvName)
234-
if (opVersion == operatorVersion) && (operator.OcpVersion == ocpVersion || ocpVersion == "") && operator.Channel == channel {
235-
return true
226+
for _, url := range catalogUrls {
227+
log.Trace(url)
228+
if responseData, err = validator.GetRequest(url); err != nil || len(responseData) == 0 {
229+
return false
230+
}
231+
operatorEntries := offlinecheck.OperatorCatalog{}
232+
err = json.Unmarshal(responseData, &operatorEntries)
233+
if err != nil {
234+
log.Error("Cannot marshall binary data", err)
235+
return false
236+
}
237+
for _, operator := range operatorEntries.Data {
238+
_, opVersion := offlinecheck.ExtractNameVersionFromName(operator.CsvName)
239+
if (opVersion == operatorVersion) && (operator.OcpVersion == ocpVersion || ocpVersion == "") && operator.Channel == channel {
240+
return true
241+
}
236242
}
237243
}
238244
return false

0 commit comments

Comments
 (0)