Cloudwatch: Fix Unexpected error (#74420)
Fix unexpected error when creating a new cloudwatch datasource. Involves a fair amount of refactoring, so if this causes unexpected issues related to region fetching we can turn this off with the cloudwatchNewRegionsHandler feature toggle, although we do not predict it will so we are enabling it to default to true and hope to remove it shortly.
This commit is contained in:
@@ -21,6 +21,7 @@ type RequestContext struct {
|
||||
MetricsClientProvider MetricsClientProvider
|
||||
LogsAPIProvider CloudWatchLogsAPIProvider
|
||||
OAMAPIProvider OAMAPIProvider
|
||||
EC2APIProvider EC2APIProvider
|
||||
Settings CloudWatchSettings
|
||||
Features featuremgmt.FeatureToggles
|
||||
}
|
||||
@@ -41,6 +42,10 @@ type AccountsProvider interface {
|
||||
GetAccountsForCurrentUserOrRole() ([]resources.ResourceResponse[resources.Account], error)
|
||||
}
|
||||
|
||||
type RegionsAPIProvider interface {
|
||||
GetRegions() ([]resources.ResourceResponse[resources.Region], error)
|
||||
}
|
||||
|
||||
// Clients
|
||||
type MetricsClientProvider interface {
|
||||
ListMetricsWithPageLimit(params *cloudwatch.ListMetricsInput) ([]resources.MetricResponse, error)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package models
|
||||
|
||||
import "fmt"
|
||||
|
||||
// put misc expected user errors here
|
||||
|
||||
var ErrMissingRegion = fmt.Errorf("missing default region")
|
||||
@@ -24,6 +24,10 @@ type Account struct {
|
||||
IsMonitoringAccount bool `json:"isMonitoringAccount"`
|
||||
}
|
||||
|
||||
type Region struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Metric struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
|
||||
Reference in New Issue
Block a user