Skip to content

Commit

Permalink
chore: migrates alert_configuration to new SDK (#1630)
Browse files Browse the repository at this point in the history
* migrate alert_configuration to new sdk

* fix lint

* fix missing lint

* refactor unknown check for notifierID and remove Matcher from old sdk from tests

* set to til groupId

* merge master to INTMDB-1121

* use SafeString util method instead of accessing directly string pointer variables

* avoid risk of accessing the pointer value
  • Loading branch information
oarbusi committed Nov 21, 2023
1 parent 7dde9cc commit bc33bf4
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ func newTFAlertConfigurationDSModel(apiRespConfig *admin.GroupAlertsConfig, proj
Created: types.StringPointerValue(util.TimePtrToStringPtr(apiRespConfig.Created)),
Updated: types.StringPointerValue(util.TimePtrToStringPtr(apiRespConfig.Updated)),
Enabled: types.BoolPointerValue(apiRespConfig.Enabled),
MetricThresholdConfig: newTFMetricThresholdConfigModelV2(apiRespConfig.MetricThreshold, []tfMetricThresholdConfigModel{}),
ThresholdConfig: newTFThresholdConfigModelV2(apiRespConfig.Threshold, []tfThresholdConfigModel{}),
Notification: newTFNotificationModelListV2(apiRespConfig.Notifications, []tfNotificationModel{}),
Matcher: newTFMatcherModelListV2(apiRespConfig.Matchers, []tfMatcherModel{}),
MetricThresholdConfig: newTFMetricThresholdConfigModel(apiRespConfig.MetricThreshold, []tfMetricThresholdConfigModel{}),
ThresholdConfig: newTFThresholdConfigModel(apiRespConfig.Threshold, []tfThresholdConfigModel{}),
Notification: newTFNotificationModelList(apiRespConfig.Notifications, []tfNotificationModel{}),
Matcher: newTFMatcherModelList(apiRespConfig.Matchers, []tfMatcherModel{}),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/testutils"
matlas "go.mongodb.org/atlas/mongodbatlas"
"go.mongodb.org/atlas-sdk/v20231115001/admin"
)

func TestAccConfigDSAlertConfiguration_basic(t *testing.T) {
var (
alert = &matlas.AlertConfiguration{}
alert = &admin.GroupAlertsConfig{}
dataSourceName = "data.mongodbatlas_alert_configuration.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
Expand Down Expand Up @@ -42,7 +42,7 @@ func TestAccConfigDSAlertConfiguration_basic(t *testing.T) {

func TestAccConfigDSAlertConfiguration_withThreshold(t *testing.T) {
var (
alert = &matlas.AlertConfiguration{}
alert = &admin.GroupAlertsConfig{}
dataSourceName = "data.mongodbatlas_alert_configuration.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAccConfigDSAlertConfiguration_withThreshold(t *testing.T) {

func TestAccConfigDSAlertConfiguration_withOutput(t *testing.T) {
var (
alert = &matlas.AlertConfiguration{}
alert = &admin.GroupAlertsConfig{}
dataSourceName = "data.mongodbatlas_alert_configuration.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestAccConfigDSAlertConfiguration_withOutput(t *testing.T) {

func TestAccConfigDSAlertConfiguration_withPagerDuty(t *testing.T) {
var (
alert = &matlas.AlertConfiguration{}
alert = &admin.GroupAlertsConfig{}
dataSourceName = "data.mongodbatlas_alert_configuration.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acctest.RandomWithPrefix("test-acc")
Expand Down

0 comments on commit bc33bf4

Please sign in to comment.