Skip to content

Commit

Permalink
operator: add redhat-operators organizacion check in the catalog (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontesi authored Nov 16, 2023
1 parent fc1d120 commit a10365d
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions pkg/certdb/onlinecheck/onlinecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
// Here we are using only External endpoint to collect published containers and operator information

const filterCertifiedOperatorsOrg = "organization==certified-operators"
const filterRedHatOperatorsOrg = "organization==redhat-operators"
const certifiedOperatorsCatalogURL = "https://catalog.redhat.com/api/containers/v1/operators/bundles?page_size=100&page=0&filter=csv_name==%s;%s"
const certifiedContainerCatalogURL = "https://catalog.redhat.com/api/containers/v1/repositories/registry/%s/repository/%s/images?"
const certifiedContainerCatalogDigestURL = "https://catalog.redhat.com/api/containers/v1/images?filter=image_id==%s"
Expand Down Expand Up @@ -218,21 +219,26 @@ func (validator OnlineValidator) IsOperatorCertified(csvName, ocpVersion, channe
_, operatorVersion := offlinecheck.ExtractNameVersionFromName(csvName)
var responseData []byte
var err error
url := fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterCertifiedOperatorsOrg)
log.Trace(url)
if responseData, err = validator.GetRequest(url); err != nil || len(responseData) == 0 {
return false
}
operatorEntries := offlinecheck.OperatorCatalog{}
err = json.Unmarshal(responseData, &operatorEntries)
if err != nil {
log.Error("Cannot marshall binary data", err)
return false
catalogUrls := []string{
fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterCertifiedOperatorsOrg),
fmt.Sprintf(certifiedOperatorsCatalogURL, csvName, filterRedHatOperatorsOrg),
}
for _, operator := range operatorEntries.Data {
_, opVersion := offlinecheck.ExtractNameVersionFromName(operator.CsvName)
if (opVersion == operatorVersion) && (operator.OcpVersion == ocpVersion || ocpVersion == "") && operator.Channel == channel {
return true
for _, url := range catalogUrls {
log.Trace(url)
if responseData, err = validator.GetRequest(url); err != nil || len(responseData) == 0 {
return false
}
operatorEntries := offlinecheck.OperatorCatalog{}
err = json.Unmarshal(responseData, &operatorEntries)
if err != nil {
log.Error("Cannot marshall binary data", err)
return false
}
for _, operator := range operatorEntries.Data {
_, opVersion := offlinecheck.ExtractNameVersionFromName(operator.CsvName)
if (opVersion == operatorVersion) && (operator.OcpVersion == ocpVersion || ocpVersion == "") && operator.Channel == channel {
return true
}
}
}
return false
Expand Down

0 comments on commit a10365d

Please sign in to comment.