-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_dashboard_grafana_managed_private_endpoint
#27781
Conversation
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource_test.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource_test.go
Outdated
Show resolved
Hide resolved
Co-authored-by: stephybun <[email protected]>
@stephybun I have updated everything requested. New acceptance tests output: $ make acctests SERVICE='dashboard' TESTARGS='-run=TestAccDashboardGrafanaManagedPrivateEndpoint_' TESTTIMEOUT='60m'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/dashboard -run=TestAccDashboardGrafanaManagedPrivateEndpoint_ -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_basic
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_basic (693.02s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_requiresImport
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_requiresImport (753.50s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_complete
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_complete (654.78s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_update
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_update (751.20s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/dashboard 2852.512s Thanks for the thorough review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djryanj it looks like some of the comments weren't resolved fully. I left another round of comments around consistency, once those are fixed up properly this should be good to go.
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
properties := resp.Model | ||
|
||
if metadata.ResourceData.HasChange("tags") { | ||
properties.Tags = &model.Tags | ||
} | ||
|
||
if err := client.CreateThenPoll(ctx, *id, *properties); err != nil { | ||
return fmt.Errorf("updating %s: %+v", *id, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In nearly all cases the Model
has a field called Properties
which is why we follow the naming convention of model := resp.Model
and props := model.Properties
. For clarity and consistency can you please update this to
properties := resp.Model | |
if metadata.ResourceData.HasChange("tags") { | |
properties.Tags = &model.Tags | |
} | |
if err := client.CreateThenPoll(ctx, *id, *properties); err != nil { | |
return fmt.Errorf("updating %s: %+v", *id, err) | |
} | |
model := resp.Model | |
if metadata.ResourceData.HasChange("tags") { | |
model.Tags = &model.Tags | |
} | |
if err := client.CreateThenPoll(ctx, *id, *model); err != nil { | |
return fmt.Errorf("updating %s: %+v", *id, err) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephybun I believe I have resolved this, but please double check; I had to modify the variable assigned to the model created in line 235. I hope this maintains consistency.
internal/services/dashboard/dashboard_grafana_managed_private_endpoint_resource.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/parse/managed_private_endpoint_test.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/validate/managed_private_endpoint_id.go
Outdated
Show resolved
Hide resolved
internal/services/dashboard/validate/managed_private_endpoint_id_test.go
Outdated
Show resolved
Hide resolved
Updated per request; new acceptance test output: $ make acctests SERVICE='dashboard' TESTARGS='-run=TestAccDashboardGrafanaManagedPrivateEndpoint_' TESTTIMEOUT='60m'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/dashboard -run=TestAccDashboardGrafanaManagedPrivateEndpoint_ -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_basic
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_basic (744.02s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_requiresImport
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_requiresImport (668.98s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_complete
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_complete (653.80s)
=== RUN TestAccDashboardGrafanaManagedPrivateEndpoint_update
--- PASS: TestAccDashboardGrafanaManagedPrivateEndpoint_update (671.82s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/dashboard 2738.636s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes @djryanj. Apologies if the review comments were confusing or unclear. A lot of this code is boilerplate and yet we unfortunately end up with a lot of variation within the provider. The contributor guide on adding a new resource or data source are good references to follow and contain the pattern that we expect to see in PRs.
The tests are passing so this looks ready to go in, LGTM 🍓
return err | ||
} | ||
|
||
var mpe ManagedPrivateEndpointModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be fixed now but for future reference, we usually instantiate the schema model as one of model
, config
, state
model := resp.Model | ||
if resp.Model == nil { | ||
return fmt.Errorf("retrieving %s: `model` was nil", id) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also minor and doesn't need to be fixed now
model := resp.Model | |
if resp.Model == nil { | |
return fmt.Errorf("retrieving %s: `model` was nil", id) | |
} | |
if resp.Model == nil { | |
return fmt.Errorf("retrieving %s: `model` was nil", id) | |
} | |
model := resp.Model |
Alternatively resp.Model
can be assigned to payload
instead of model
@stephybun thanks so much for your patience and guidance, it is very appreciated. Go isn't my strongest language, but as usual had I RTFM I think I would have had better success earlier on. In terms of correcting those last few remaining items, I'm happy to open another PR with those few changes; it's not massive and if it's better for the project to maintain that consistency then I'm happy to do it. |
You're welcome @djryanj! We would absolutely appreciate a PR to fix up those minor inconsistencies (it would also be acceptable to add it in to your other PR that you opened recently) but also not a huge deal if not. It'll be updated at some point when someone in the team comes across it. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Description
This PR adds
azurerm_dashboard_grafana_managed_private_endpoint
as requested in #23950. Includes documentation and acceptance tests.Note: auto-approval of the managed endpoints is not possible via this resource (and is noted in the documentation). Other resources are required for that, since the approval must happen on the destination resource.
Sidenote: This is a cleaner PR than one previously submitted.
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_dashboard_grafana_managed_private_endpoint
- [Support for azurerm_dashboard_grafana managed private endpoints #23950]This is a (please select all that apply):
Related Issue(s)
Fixes #23950
Note
If this PR changes meaningfully during the course of review please update the title and description as required.