From 2e1095c22385550704f615cfe032dee2e0000084 Mon Sep 17 00:00:00 2001 From: Jiawei Tao Date: Tue, 14 Jan 2025 13:56:49 +0800 Subject: [PATCH] address comments --- .../dynatrace/dynatrace_monitors_data_source.go | 2 +- .../dynatrace/dynatrace_monitors_resource.go | 2 +- .../dynatrace/dynatrace_monitors_resource_test.go | 12 ++++++------ internal/services/dynatrace/helper.go | 15 +++++++-------- website/docs/d/dynatrace_monitors.html.markdown | 8 ++++---- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/internal/services/dynatrace/dynatrace_monitors_data_source.go b/internal/services/dynatrace/dynatrace_monitors_data_source.go index 38b0b9678ee9..d7f2196599a5 100644 --- a/internal/services/dynatrace/dynatrace_monitors_data_source.go +++ b/internal/services/dynatrace/dynatrace_monitors_data_source.go @@ -204,7 +204,7 @@ func (d MonitorsDataSource) Read() sdk.ResourceFunc { Identity: identityProps, EnvironmentProperties: FlattenDynatraceEnvironmentProperties(props.DynatraceEnvironmentProperties), PlanData: FlattenDynatracePlanData(props.PlanData), - UserInfo: FlattenDynatraceUserInfo(metadata.ResourceData.Get("user").([]interface{})), + UserInfo: FlattenDynatraceUserInfo(props.UserInfo), } if model.Tags != nil { monitorResource.Tags = pointer.From(model.Tags) diff --git a/internal/services/dynatrace/dynatrace_monitors_resource.go b/internal/services/dynatrace/dynatrace_monitors_resource.go index 4298172e9238..66a89b8aac91 100644 --- a/internal/services/dynatrace/dynatrace_monitors_resource.go +++ b/internal/services/dynatrace/dynatrace_monitors_resource.go @@ -277,7 +277,7 @@ func (r MonitorsResource) Read() sdk.ResourceFunc { MarketplaceSubscriptionStatus: string(*props.MarketplaceSubscriptionStatus), Identity: identityProps, PlanData: FlattenDynatracePlanData(props.PlanData), - UserInfo: FlattenDynatraceUserInfo(metadata.ResourceData.Get("user").([]interface{})), + UserInfo: FlattenDynatraceUserInfo(props.UserInfo), } if model.Tags != nil { diff --git a/internal/services/dynatrace/dynatrace_monitors_resource_test.go b/internal/services/dynatrace/dynatrace_monitors_resource_test.go index 10d786fcf873..5e4c31e98765 100644 --- a/internal/services/dynatrace/dynatrace_monitors_resource_test.go +++ b/internal/services/dynatrace/dynatrace_monitors_resource_test.go @@ -155,11 +155,11 @@ resource "azurerm_dynatrace_monitor" "test" { } user { - first_name = "Alice" - last_name = "Bobab" - email = "agarwald@microsoft.com" - phone_number = "123456" - country = "westus" + first_name = "%s" + last_name = "%s" + email = "%s" + phone_number = "%s" + country = "%s" } plan { @@ -172,7 +172,7 @@ resource "azurerm_dynatrace_monitor" "test" { environment = "Dev" } } -`, template, data.RandomInteger) +`, template, data.RandomInteger, r.dynatraceInfo.UserFirstName, r.dynatraceInfo.UserLastName, r.dynatraceInfo.UserEmail, r.dynatraceInfo.UserPhoneNumber, r.dynatraceInfo.UserCountry) } func (r MonitorsResource) updated(data acceptance.TestData) string { diff --git a/internal/services/dynatrace/helper.go b/internal/services/dynatrace/helper.go index 68b08723f6bf..7af87dd5970a 100644 --- a/internal/services/dynatrace/helper.go +++ b/internal/services/dynatrace/helper.go @@ -98,19 +98,18 @@ func FlattenDynatracePlanData(input *monitors.PlanData) []PlanData { } } -func FlattenDynatraceUserInfo(input []interface{}) []UserInfo { - if len(input) == 0 { +func FlattenDynatraceUserInfo(input *monitors.UserInfo) []UserInfo { + if input == nil { return []UserInfo{} } - v := input[0].(map[string]interface{}) return []UserInfo{ { - Country: v["country"].(string), - EmailAddress: v["email"].(string), - FirstName: v["first_name"].(string), - LastName: v["last_name"].(string), - PhoneNumber: v["phone_number"].(string), + Country: pointer.From(input.Country), + EmailAddress: pointer.From(input.EmailAddress), + FirstName: pointer.From(input.FirstName), + LastName: pointer.From(input.LastName), + PhoneNumber: pointer.From(input.PhoneNumber), }, } } diff --git a/website/docs/d/dynatrace_monitors.html.markdown b/website/docs/d/dynatrace_monitors.html.markdown index 9b39a5708d0e..d88854b5831e 100644 --- a/website/docs/d/dynatrace_monitors.html.markdown +++ b/website/docs/d/dynatrace_monitors.html.markdown @@ -50,13 +50,13 @@ In addition to the Arguments listed above - the following Attributes are exporte --- -A `identity` block supports the following: +An `identity` block exports the following: -* `type` - The type of identity used for the resource. Only possible value is `SystemAssigned`. +* `type` - The type of identity used for the resource. --- -A `plan` block supports the following: +A `plan` block exports the following: * `billing_cycle` - Different billing cycles. @@ -68,7 +68,7 @@ A `plan` block supports the following: --- -A `user` block supports the following: +A `user` block exports the following: * `country` - Country of the user.