Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: azurerm_dynatrace_monitor #27432

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

jiaweitao001
Copy link
Contributor

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • New Resource: azurerm_dynatrace_monitor

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

As discussed several months ago, since the tests of this resource cost too much, I'll perform tests on the subs provided by the service team. Here's the test results.

PASS: TestAccDynatraceMonitor_basic (394.27s)
PASS: TestAccDynatraceMonitor_update(456.12s)
PASS: TestAccDynatraceMonitor_requiresImport(387.24s)

Comment on lines 164 to 86
country := v["country"].(string)
emailAddress := v["email"].(string)
firstName := v["first_name"].(string)
lastName := v["last_name"].(string)
phoneNumber := v["phone_number"].(string)

return []UserInfo{
{
Country: country,
EmailAddress: emailAddress,
FirstName: firstName,
LastName: lastName,
PhoneNumber: phoneNumber,
},
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we please just inline these?

Suggested change
country := v["country"].(string)
emailAddress := v["email"].(string)
firstName := v["first_name"].(string)
lastName := v["last_name"].(string)
phoneNumber := v["phone_number"].(string)
return []UserInfo{
{
Country: country,
EmailAddress: emailAddress,
FirstName: firstName,
LastName: lastName,
PhoneNumber: phoneNumber,
},
}
return []UserInfo{
{
Country: v["country"].(string),
EmailAddress: v["email"].(string),
FirstName: v["first_name"].(string),
LastName: lastName,
PhoneNumber: phoneNumber,
},
}

etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Comment on lines 22 to 23
"MONTHLY",
"WEEKLY",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not enums.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other APIs correctly make these an enum (ie sql_license_type) so i presume this is a swagger oversite, could we create a quick rest api specs issue and the link that inline?

Comment on lines 37 to 38
"PAYG",
"COMMITTED",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, these are not enums.

"email": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can propertly validate this is an email?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Comment on lines 82 to 84
"plan": SchemaPlanData(),

"user": SchemaUserInfo(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we are pulling these out into a function? they are only used here so could we please inline them to be consistant with the rest of the provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will inline them.

Comment on lines 75 to 76
"Active",
"Suspended",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.


A `plan` block supports the following:

* `billing_cycle` - (Optional) Different billing cycles. Possible values are `MONTHLY`, `WEEKLY`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comma's are not used for two item list

Suggested change
* `billing_cycle` - (Optional) Different billing cycles. Possible values are `MONTHLY`, `WEEKLY`.
* `billing_cycle` - (Optional) Different billing cycles. Possible values are `MONTHLY` and `WEEKLY`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.


* `identity` - (Required) The kind of managed identity assigned to this resource. A `identity` block as defined below.

* `marketplace_subscription` - (Required) Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state. Possible values are `Active`, `Suspended`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.


* `plan` - (Required) Plan id as published by Dynatrace.

* `usage_type` - (Optional) Different usage type. Possible values are `PAYG`, `COMMITTED`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 minor comments + the rest API specs for the missing enum but otherwise LGTM once they are resolved 🏷️

monitoringStatus = monitors.MonitoringStatusDisabled
}
monitorsProps := monitors.MonitorProperties{
MarketplaceSubscriptionStatus: pointer.To(marketplaceSubscriptionServiceStatus),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be

Suggested change
MarketplaceSubscriptionStatus: pointer.To(marketplaceSubscriptionServiceStatus),
MarketplaceSubscriptionStatus: pointer.To(monitors.MarketplaceSubscriptionStatus(model.MarketplaceSubscriptionStatus)),

?

Comment on lines 251 to 252
}
if model := resp.Model; model != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
if model := resp.Model; model != nil {
}
if model := resp.Model; model != nil {

MarketplaceSubscriptionStatus: string(*props.MarketplaceSubscriptionStatus),
Identity: identityProps,
PlanData: FlattenDynatracePlanData(props.PlanData),
UserInfo: FlattenDynatraceUserInfo(userInfo),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be

Suggested change
UserInfo: FlattenDynatraceUserInfo(userInfo),
UserInfo: FlattenDynatraceUserInfo(metadata.ResourceData.Get("user").([]interface{})),

?

@katbyte
Copy link
Collaborator

katbyte commented Oct 29, 2024

@jiaweitao001 also don't forget to post test evidence

@jiaweitao001
Copy link
Contributor Author

@jiaweitao001 also don't forget to post test evidence

Hi @katbyte , the test results are listed in the description note at the top.

@katbyte
Copy link
Collaborator

katbyte commented Oct 29, 2024

@jiaweitao001 - you need to rerun the tests with all the changes/commits made to ensure it still works, and tests should be a comment after the changes have been made. Please re-run the tests and add as a comment.

@jiaweitao001
Copy link
Contributor Author

@jiaweitao001 - you need to rerun the tests with all the changes/commits made to ensure it still works, and tests should be a comment after the changes have been made. Please re-run the tests and add as a comment.

Latest test results:

=== RUN   TestAccDynatraceMonitor_basic
=== PAUSE TestAccDynatraceMonitor_basic
=== RUN   TestAccDynatraceMonitor_update
=== PAUSE TestAccDynatraceMonitor_update
=== RUN   TestAccDynatraceMonitor_requiresImport
=== PAUSE TestAccDynatraceMonitor_requiresImport
=== CONT  TestAccDynatraceMonitor_basic
=== CONT  TestAccDynatraceMonitor_requiresImport
=== CONT  TestAccDynatraceMonitor_update
--- PASS: TestAccDynatraceMonitor_requiresImport (293.30s)
--- PASS: TestAccDynatraceMonitor_basic (300.87s)
--- PASS: TestAccDynatraceMonitor_update (328.71s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/dynatrace     328.748s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants