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
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,19 @@ generate-dashboards:
## @Helpers - Deprecated implementations

.PHONY: generate-deprecate-green ## This method should be remove soon. It is only an internal helper
generate-deprecate-green: ## 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.8_2021-08-16.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.8_2021-08-16.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-15.json
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-22.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-22.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-21.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-22.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-22.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-21.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.8_2021-08-16.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.8_2021-08-16.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-08-22.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-22.json

Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@
// deprecated on 4.9. That will be removed as soon as possible and is just added
// here in case it be required to be checked and used so far.
// The following script uses the JSON format output image to
// generates the deprecate.yml file with all bundles which requires
// generates the yml file with all bundles which requires
// to be deprecated because are using the APIs which will be removed on ocp 4.9 .
// Example of usage: (see that we leave makefile target to help you out here)
// nolint: lll
// 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.8_2021-08-10.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.8_2021-08-06.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-15.json
package main

import (
"encoding/json"
"flag"
"log"
"os"
"path/filepath"
"sort"
"strings"
"text/template"

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

"github.com/operator-framework/audit/pkg"
"github.com/operator-framework/audit/pkg/reports/bundles"
)
Expand All @@ -46,6 +54,7 @@ type Deprecated struct {

type File struct {
Deprecated []Deprecated
APIDashReport *custom.APIDashReport
}

//nolint: lll
Expand All @@ -56,10 +65,17 @@ func main() {
log.Fatal(err)
}

// Update here the path of the JSON report for the image that you would like to be used
path := "testdata/reports/redhat_redhat_operator_index/bundles_registry.redhat.io_redhat_redhat_operator_index_v4.8_2021-08-07.json"
defaultOutputPath := "hack/scripts/deprecated-bundles-repo/deprecate-all"

var outputPath string
var jsonFile string

flag.StringVar(&outputPath, "output", defaultOutputPath, "Inform the path for output the report, if not informed it will be generated at hack/scripts/deprecated-bundles-repo/deprecate-green.")
flag.StringVar(&jsonFile, "image", "", "Inform the path for the JSON result which will be used to generate the report. ")

flag.Parse()

byteValue, err := pkg.ReadFile(filepath.Join(currentPath, path))
byteValue, err := pkg.ReadFile(filepath.Join(currentPath, jsonFile))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -105,6 +121,11 @@ func main() {
mapPackagesWithBundles[""] = all
}

apiDashReport, err := getAPIDashForImage(jsonFile)
if err != nil {
log.Fatal(err)
}

// filter by all pkgs which has only deprecated APIs
hasDeprecated := make(map[string][]bundles.Column)
for key, bundles := range mapPackagesWithBundles {
Expand Down Expand Up @@ -140,17 +161,31 @@ func main() {
return allDeprecated[i].PackageName < allDeprecated[j].PackageName
})

f, err := os.Create(filepath.Join(currentPath, "hack/scripts/deprecated-bundles-repo/deprecate-all/deprecated.yml"))
fp := filepath.Join(currentPath, outputPath, pkg.GetReportName(apiDashReport.ImageName, "deprecated", "yml"))
f, err := os.Create(fp)
if err != nil {
log.Fatal(err)
}

defer f.Close()

t := template.Must(template.ParseFiles(filepath.Join(currentPath, "hack/scripts/deprecated-bundles-repo/deprecate-all/template.go.tmpl")))
err = t.Execute(f, File{allDeprecated})
err = t.Execute(f, File{Deprecated: allDeprecated, APIDashReport: apiDashReport})
if err != nil {
panic(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
}
Loading