Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
**/testdata/reports/ivs/**
**/testdata/reports/contacts/**
**/testdata/reports/deprecate-all/**
**/testdata/reports/deprecate-green/**
**/testdata/reports/deprecate-green/**
**/testdata/reports/deprecate-json/**
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,28 @@ all-deprecated: install

.PHONY: generate-deprecate-green ## This method should be remove soon. It is only an internal helper
generate-deprecate-green: install ## ensure that you have update the the date of the report.
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-09-05.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-09-05.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-green/deprecated_index.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.9_2021-09-05.json

.PHONY: generate-deprecate-all ## This method should be remove soon. It is only an internal helper
generate-deprecate-all: install ## ensure that you have update the the date of the report.
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-08-29.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-09-05.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-09-05.json
go run ./hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated_index.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.9_2021-09-05.json

.PHONY: generate-pkgs ## This method should be remove soon. It is only an internal helper
generate-pkgs: ## ensure that you have update the the date of the report.
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.8_2021-08-29.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-08-29.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-08-29.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_community_operator_index/bundles_registry.redhat.io_redhat_community_operator_index_v4.8_2021-08-28.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.8_2021-09-04.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.8_2021-09-04.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-09-04.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_community_operator_index/bundles_registry.redhat.io_redhat_community_operator_index_v4.8_2021-09-05.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-09-05.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-09-05.json
go run ./hack/scripts/packages/generate.go --image=testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.9_2021-09-05.json

.PHONY: generate-ivs-report ## This method should be remove soon. It is only an internal helper
generate-ivs-report: ## ensure that you have the mongo json file and update the the date of the report.
go run hack/scripts/ivs-emails/generate.go --mongo=hack/scripts/ivs-emails/mongo-query-join-results-prod.json --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-08-29.json
go run hack/scripts/ivs-emails/generate.go --mongo=hack/scripts/ivs-emails/mongo-query-join-results-prod.json --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-08-29.json
go run hack/scripts/ivs-emails/generate.go --mongo=hack/scripts/ivs-emails/mongo-query-join-results-prod.json --image=testdata/reports/redhat_certified_operator_index/bundles_registry.redhat.io_redhat_certified_operator_index_v4.9_2021-09-05.json
go run hack/scripts/ivs-emails/generate.go --mongo=hack/scripts/ivs-emails/mongo-query-join-results-prod.json --image=testdata/reports/redhat_redhat_marketplace_index/bundles_registry.redhat.io_redhat_redhat_marketplace_index_v4.9_2021-09-05.json

3 changes: 2 additions & 1 deletion hack/grade/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func main() {

// Ignore the tag images 4.6 and 4.7
if strings.Contains(info.Name(), "v4.7") ||
strings.Contains(info.Name(), "v4.6") {
strings.Contains(info.Name(), "v4.6") ||
strings.Contains(info.Name(), "v4.8") {
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions hack/report/bundles/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ func main() {
//"registry.redhat.io/redhat/community-operator-index:v4.9": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-marketplace-index:v4.9": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-operator-index:v4.9": "https://registry.redhat.io",
"registry.redhat.io/redhat/certified-operator-index:v4.8": "https://registry.redhat.io",
"registry.redhat.io/redhat/community-operator-index:v4.8": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-marketplace-index:v4.8": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-operator-index:v4.8": "https://registry.redhat.io",
"quay.io/operatorhubio/catalog:latest": "https://registry.connect.redhat.com",
}

Expand Down Expand Up @@ -102,6 +99,9 @@ func main() {
"registry.redhat.io/redhat/community-operator-index:v4.6": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-marketplace-index:v4.6": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-operator-index:v4.6": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-marketplace-index:v4.8": "https://registry.redhat.io",
"registry.redhat.io/redhat/redhat-operator-index:v4.8": "https://registry.redhat.io",
"registry.redhat.io/redhat/certified-operator-index:v4.8": "https://registry.redhat.io",
}

indexReportKinds = []string{"bundles"}
Expand Down
106 changes: 106 additions & 0 deletions hack/scripts/compare/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2021 The Audit Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Deprecated
// This script is only a helper for we are able to compare to JSON files
// and check what packages were defined in one and are no longer in the other
// one. E.g After send a test to iib I want to know what packages in green
// were in the JSON A which are no longer in its result JSON B
// todo: remove after 4.9-GA

package main

import (
"encoding/json"
"log"
"os"
"path/filepath"

"github.com/operator-framework/audit/hack"
"github.com/operator-framework/audit/pkg/reports/custom"
)

//nolint:lll
func main() {

jsonFinalResult := "my-test.json"
jsonOrigin := "testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-08-29.json"

apiDashReportOrigin, err := getAPIDashForImage(jsonOrigin)
if err != nil {
log.Fatal(err)
}

currentPath, err := os.Getwd()
if err != nil {
log.Fatal(err)
}

file := filepath.Join(currentPath, jsonFinalResult)

apiDashReportFinalResult, err := getAPIDashForImage(file)
if err != nil {
log.Fatal(err)
}

// Check all that was in green that is no longer in the final result
var notFound []custom.OK
for _, v := range apiDashReportOrigin.OK {
found := false
for _, i := range apiDashReportFinalResult.OK {
if v.Name == i.Name {
found = true
break
}
}
if !found {
notFound = append(notFound, v)
}
}

reportPath := filepath.Join(currentPath)

// Creates the compare.json with all packages and bundles data that were
// in the origin and are no longer in the result
fp := filepath.Join(reportPath, "compare.json")
f, err := os.Create(fp)
if err != nil {
log.Fatal(err)
}

defer f.Close()

jsonResult, err := json.MarshalIndent(notFound, "", "\t")
if err != nil {
log.Fatal(err)
}

err = hack.ReplaceInFile(fp, "", string(jsonResult))
if err != nil {
log.Fatal(err)
}
}

func getAPIDashForImage(image string) (*custom.APIDashReport, error) {
// Update here the path of the JSON report for the image that you would like to be used
custom.Flags.File = image

bundlesReport, err := custom.ParseBundlesJSONReport()
if err != nil {
log.Fatal(err)
}

apiDashReport := custom.NewAPIDashReport(bundlesReport)
return apiDashReport, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type File struct {
APIDashReport *custom.APIDashReport
}

//nolint: lll
//nolint: lll,gocyclo
func main() {

currentPath, err := os.Getwd()
Expand Down Expand Up @@ -134,7 +134,9 @@ func main() {
hasDeprecated := make(map[string][]bundles.Column)
for key, bundles := range mapPackagesWithBundles {
for _, b := range bundles {
if len(b.KindsDeprecateAPIs) > 0 {
// If has UNKNOW status we need ignore that means an error when we tried to check
// the results
if len(b.KindsDeprecateAPIs) > 0 && len(b.DeprecateAPIsManifests[pkg.Unknown]) == 0 {
hasDeprecated[key] = mapPackagesWithBundles[key]
}
}
Expand All @@ -144,6 +146,19 @@ func main() {
// see that we need to remove the redhat registry domain
allDeprecated := []Deprecated{}
for key, bundles := range hasDeprecated {

// do not add a package that has no bundles to be deprecated
found := false
for _, b := range bundles {
// We just ONLY the bundles which are using the removed APIS
if len(b.KindsDeprecateAPIs) > 0 && len(b.DeprecateAPIsManifests[pkg.Unknown]) == 0 {
found = true
}
}
if !found {
continue
}

deprecatedYaml := Deprecated{PackageName: key}

// nolint:scopelint
Expand All @@ -152,11 +167,14 @@ func main() {
})

for _, b := range bundles {
deprecatedYaml.Bundles = append(deprecatedYaml.Bundles,
Bundles{
Paths: strings.ReplaceAll(b.BundleImagePath, "registry.redhat.io/", ""),
Details: b.BundleName,
})
// We just ONLY the bundles which are using the removed APIS
if len(b.KindsDeprecateAPIs) > 0 && len(b.DeprecateAPIsManifests[pkg.Unknown]) == 0 {
deprecatedYaml.Bundles = append(deprecatedYaml.Bundles,
Bundles{
Paths: b.BundleImagePath,
Details: b.BundleName,
})
}
}
allDeprecated = append(allDeprecated, deprecatedYaml)
}
Expand All @@ -183,6 +201,37 @@ func main() {
panic(err)
}

//To generate in the JSON format to allow us to do the test
var onlyBundles []string
for _, a := range allDeprecated {
for _, ab := range a.Bundles {
onlyBundles = append(onlyBundles, ab.Paths)
}

}

reportPath = filepath.Join(currentPath, hack.ReportsPath, "deprecate-json")
command = exec.Command("mkdir", reportPath)
_, _ = pkg.RunCommand(command)

fp = filepath.Join(reportPath, pkg.GetReportName(apiDashReport.ImageName, "deprecate-all", "json"))
f, err = os.Create(fp)
if err != nil {
log.Fatal(err)
}

defer f.Close()

jsonResult, err := json.MarshalIndent(onlyBundles, "", "\t")
if err != nil {
log.Fatal(err)
}

err = hack.ReplaceInFile(fp, "", string(jsonResult))
if err != nil {
log.Fatal(err)
}

}

func getAPIDashForImage(image string) (*custom.APIDashReport, error) {
Expand Down
Loading