CloudWatch: Use context in aws DescribeRegionsWithContext (#76922)
* Use context in aws DescribeRegionsWithContext In the current way, DescribeRegions is used which doesn't allow cancelling the request if the context changes. Using DescribeRegionsWithContext is the preferred way. * Fix context variable * Revert GetRegionsWithContext to GetRegions GetRegions is not an AWS SDK method. Hence, GetRegions should be enough as the name change is not needed for context implementation.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
@@ -12,7 +14,7 @@ type RegionsService struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (r *RegionsService) GetRegions() ([]resources.ResourceResponse[resources.Region], error) {
|
||||
func (r *RegionsService) GetRegions(ctx context.Context) (in []resources.ResourceResponse[resources.Region], e error) {
|
||||
args := r.Called()
|
||||
return args.Get(0).(([]resources.ResourceResponse[resources.Region])), args.Error(1)
|
||||
}
|
||||
@@ -21,7 +23,7 @@ type EC2Mock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (e *EC2Mock) DescribeRegions(in *ec2.DescribeRegionsInput) (*ec2.DescribeRegionsOutput, error) {
|
||||
func (e *EC2Mock) DescribeRegionsWithContext(ctx aws.Context, in *ec2.DescribeRegionsInput, opts ...request.Option) (*ec2.DescribeRegionsOutput, error) {
|
||||
args := e.Called()
|
||||
return args.Get(0).(*ec2.DescribeRegionsOutput), args.Error(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user