Skip to content

Commit

Permalink
feat: added paginator
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRieske committed May 14, 2024
1 parent 92ced03 commit 2473e2c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions internal/service/ec2/findv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,26 @@ func FindCarrierGatewayByID(ctx context.Context, conn *ec2.Client, id string) (*
}

func FindCarrierGateways(ctx context.Context, conn *ec2.Client, input *ec2.DescribeCarrierGatewaysInput) ([]awstypes.CarrierGateway, error) {
output, err := conn.DescribeCarrierGateways(ctx, input)
var output []awstypes.CarrierGateway

if tfawserr.ErrCodeEquals(err, errCodeInvalidCarrierGatewayIDNotFound) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
pages := ec2.NewDescribeCarrierGatewaysPaginator(conn, input)
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidCarrierGatewayIDNotFound) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}
}

if err != nil {
return nil, err
if err != nil {
return nil, err
}

output = append(output, page.CarrierGateways...)

}

Check failure on line 523 in internal/service/ec2/findv2.go

View workflow job for this annotation

GitHub Actions / 2 of 2

unnecessary trailing newline (whitespace)

return output.CarrierGateways, nil
return output, nil
}

0 comments on commit 2473e2c

Please sign in to comment.