CloudWatch: Refactor around handleGetRegions (#65713)

* Create minimal EC2 interface

* convert regions variable to a function returning a copy

* Add test for multiple calls to regions to check regionsCache

* Add returns to handler after error

* Refactor handleGetRegions
This commit is contained in:
Shirley
2023-04-11 19:55:57 +02:00
committed by GitHub
parent 92e591d2e1
commit ae23ef5b41
8 changed files with 129 additions and 42 deletions
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
"github.com/aws/aws-sdk-go/service/oam"
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi/resourcegroupstaggingapiiface"
@@ -53,7 +52,7 @@ var NewCWLogsClient = func(sess *session.Session) cloudwatchlogsiface.CloudWatch
// EC2 client factory.
//
// Stubbable by tests.
var newEC2Client = func(provider client.ConfigProvider) ec2iface.EC2API {
var newEC2Client = func(provider client.ConfigProvider) models.EC2APIProvider {
return ec2.New(provider)
}