Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaweitao001 committed Jan 14, 2025
1 parent 36e729f commit 2e1095c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/services/dynatrace/dynatrace_monitors_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions internal/services/dynatrace/dynatrace_monitors_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
15 changes: 7 additions & 8 deletions internal/services/dynatrace/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
}
8 changes: 4 additions & 4 deletions website/docs/d/dynatrace_monitors.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand Down

0 comments on commit 2e1095c

Please sign in to comment.