From a429c6fecb1a6b6e1f5112d57a1cd39f946aae3f Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 21 Jan 2025 17:23:54 -0800 Subject: [PATCH] save --- pkg/remote/awsconn/awsconn.go | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/pkg/remote/awsconn/awsconn.go b/pkg/remote/awsconn/awsconn.go index 655e1fd17..8f7731148 100644 --- a/pkg/remote/awsconn/awsconn.go +++ b/pkg/remote/awsconn/awsconn.go @@ -121,28 +121,13 @@ func ParseProfiles() map[string]struct{} { } func ListBuckets(ctx context.Context, client *s3.Client) ([]types.Bucket, error) { - var err error - var output *s3.ListBucketsOutput - var buckets []types.Bucket - region := client.Options().Region - bucketPaginator := s3.NewListBucketsPaginator(client, &s3.ListBucketsInput{BucketRegion: ®ion}) - for bucketPaginator.HasMorePages() { - output, err = bucketPaginator.NextPage(ctx) - log.Printf("output: %v", output) - if err != nil { - var apiErr smithy.APIError - if errors.As(err, &apiErr) && apiErr.ErrorCode() == "AccessDenied" { - fmt.Println("You don't have permission to list buckets for this account.") - err = apiErr - } else { - return nil, fmt.Errorf("Couldn't list buckets for your account. Here's why: %v\n", err) - } - break - } - if output == nil { - break + output, err := client.ListBuckets(ctx, &s3.ListBucketsInput{}) + if err != nil { + var apiErr smithy.APIError + if errors.As(err, &apiErr) { + return nil, fmt.Errorf("error listing buckets: %v", apiErr) } - buckets = append(buckets, output.Buckets...) + return nil, fmt.Errorf("error listing buckets: %v", err) } - return buckets, nil + return output.Buckets, nil }