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

ENG-13506: Add region to scan errors #10

Merged
merged 1 commit into from
Feb 13, 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
67 changes: 42 additions & 25 deletions aws/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading