diff --git a/aws/scan.go b/aws/scan.go index 0505af7..e35a73f 100644 --- a/aws/scan.go +++ b/aws/scan.go @@ -21,15 +21,19 @@ func scanRDSClusterRepositories( ctx context.Context, awsClient *awsClient, ) scanResponse { - repositories := []scan.Repository{} var scanErrors []error rdsClusters, err := awsClient.getRDSClusters(ctx) if err != nil { - scanErrors = append(scanErrors, fmt.Errorf( - "error scanning RDS clusters: %w", - err, - )) + scanErrors = append( + scanErrors, + fmt.Errorf( + "error scanning RDS clusters for region %s: %w", + awsClient.config.Region, + err, + ), + ) } + repositories := make([]scan.Repository, 0, len(rdsClusters)) for _, cluster := range rdsClusters { repositories = append( repositories, @@ -46,15 +50,19 @@ func scanRDSInstanceRepositories( ctx context.Context, awsClient *awsClient, ) scanResponse { - repositories := []scan.Repository{} var scanErrors []error rdsInstances, err := awsClient.getRDSInstances(ctx) if err != nil { - scanErrors = append(scanErrors, fmt.Errorf( - "error scanning RDS instances: %w", - err, - )) + scanErrors = append( + scanErrors, + fmt.Errorf( + "error scanning RDS instances for region %s: %w", + awsClient.config.Region, + err, + ), + ) } + repositories := make([]scan.Repository, 0, len(rdsInstances)) for _, instance := range rdsInstances { // Skip cluster instances, since they were already added when retrieving // the RDS clusters. @@ -75,15 +83,19 @@ func scanRedshiftRepositories( ctx context.Context, awsClient *awsClient, ) scanResponse { - repositories := []scan.Repository{} var scanErrors []error redshiftClusters, err := awsClient.getRedshiftClusters(ctx) if err != nil { - scanErrors = append(scanErrors, fmt.Errorf( - "error scanning Redshift clusters: %w", - err, - )) + scanErrors = append( + scanErrors, + fmt.Errorf( + "error scanning Redshift clusters for region %s: %w", + awsClient.config.Region, + err, + ), + ) } + repositories := make([]scan.Repository, 0, len(redshiftClusters)) for _, cluster := range redshiftClusters { repositories = append( repositories, @@ -100,15 +112,19 @@ func scanDynamoDBRepositories( ctx context.Context, awsClient *awsClient, ) scanResponse { - repositories := []scan.Repository{} var scanErrors []error dynamodbTables, err := awsClient.getDynamoDBTables(ctx) if err != nil { - scanErrors = append(scanErrors, fmt.Errorf( - "error scanning DynamoDB tables: %w", - err, - )) + scanErrors = append( + scanErrors, + fmt.Errorf( + "error scanning DynamoDB tables for region %s: %w", + awsClient.config.Region, + err, + ), + ) } + repositories := make([]scan.Repository, 0, len(dynamodbTables)) for _, table := range dynamodbTables { repositories = append( repositories, @@ -125,24 +141,25 @@ func scanS3Buckets( ctx context.Context, awsClient *awsClient, ) scanResponse { - repos := []scan.Repository{} var scanErrors []error - buckets, err := awsClient.getS3Buckets(ctx) if err != nil { scanErrors = append( scanErrors, - fmt.Errorf("error scanning S3 buckets: %w", err), + fmt.Errorf( + "error scanning S3 buckets for region %s: %w", + awsClient.config.Region, + err, + ), ) } - + repos := make([]scan.Repository, 0, len(buckets)) for _, bucket := range buckets { repos = append( repos, newRepositoryFromS3Bucket(bucket), ) } - return scanResponse{ repositories: repos, scanErrors: scanErrors,