Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added single file storage for aws data while generating report #98

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
11 changes: 11 additions & 0 deletions services/awshandler/generatereport.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func GenerateAWSReport(outFolder string) {

// Compiles and list all the stats in a single file.
regionStats := make(map[string]map[string]interface{})
allData := make(map[string]map[string]interface{})
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
Expand Down Expand Up @@ -50,8 +51,10 @@ func GenerateAWSReport(outFolder string) {
// Group stats by region
if _, exists := regionStats[regionName]; !exists {
regionStats[regionName] = make(map[string]interface{})
allData[regionName] = make(map[string]interface{})
}
regionStats[regionName][serviceName] = stats
allData[regionName][serviceName] = data
}

return nil
Expand All @@ -64,10 +67,18 @@ func GenerateAWSReport(outFolder string) {
// Print and write the report
utils.PrintNested(regionStats, "", 0)

// Storing report data
err = utils.WriteJSONToFile(outFolder+"/aws_report.json", regionStats)
if err != nil {
fmt.Println("Failed to Write the report file to json")
fmt.Println(err)
}

// Storing report data
err = utils.WriteJSONToFile(outFolder+"/aws_metadata.json", allData)
if err != nil {
fmt.Println("Failed to Write the all data file to json")
fmt.Println(err)
}

}
Loading