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

azurerm_mssql_server - updated to use parser #13151

Merged
merged 2 commits into from
Aug 27, 2021
Merged

Conversation

catriona-m
Copy link
Member

No description provided.

@catriona-m catriona-m requested a review from a team August 26, 2021 13:12
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Hi @catriona-m, this is looking great 👍

I made a couple of suggestions (the same thing in a few places) - the main one is that we can omit the Get request after creating/updating the resource since we already have the ID, and the other is making use of the String() method of the id struct to tidy up the error message strings.

If we can add those in, this should be good to merge 🚀

if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
return fmt.Errorf("checking for presence of existing SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("checking for presence of existing SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

To shorten this, we can use the String method from the id struct

Suggested change
return fmt.Errorf("checking for presence of existing SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)

if err != nil {
return fmt.Errorf("issuing create/update request for SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("issuing create/update request for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here

Suggested change
return fmt.Errorf("issuing create/update request for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
return fmt.Errorf("creating/updating %s: %+v", id, err)

}

return fmt.Errorf("waiting on create/update future for SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("waiting on create/update future for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("waiting on create/update future for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
return fmt.Errorf("waiting for creation/update of %s: %+v", id, err)

Comment on lines 252 to 256
resp, err := client.Get(ctx, resGroup, name)
resp, err := client.Get(ctx, id.ResourceGroup, id.Name)
if err != nil {
return fmt.Errorf("issuing get request for SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("issuing get request for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're only using this to retrieve the resource ID, we can forgoe the Get request and use the id struct to generate it instead

if err != nil {
return fmt.Errorf("issuing get request for SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("issuing get request for SQL Server %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}

d.SetId(*resp.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

e.g.

Suggested change
d.SetId(*resp.ID)
d.SetId(id.ID())

if err != nil {
return fmt.Errorf("creating SQL Server %q AAD admin (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("creating SQL Server %q AAD admin (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

This one could be tweaked to also use the id.String method

Suggested change
return fmt.Errorf("creating SQL Server %q AAD admin (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
return fmt.Errorf("creating AAD admin for %s: %+v", id, err)

}

if err = adminFuture.WaitForCompletionRef(ctx, adminClient.Client); err != nil {
return fmt.Errorf("waiting for creation of SQL Server %q AAD admin (Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("waiting for creation of SQL Server %q AAD admin (Resource Group %q): %+v", id.Name, id.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

if _, err = connectionClient.CreateOrUpdate(ctx, resGroup, name, connection); err != nil {
return fmt.Errorf("issuing create/update request for SQL Server %q Connection Policy (Resource Group %q): %+v", name, resGroup, err)
if _, err = connectionClient.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, connection); err != nil {
return fmt.Errorf("issuing create/update request for SQL Server %q Connection Policy (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here

if err != nil {
return fmt.Errorf("issuing create/update request for SQL Server %q Blob Auditing Policies(Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("issuing create/update request for SQL Server %q Blob Auditing Policies(Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

}

if err = auditingFuture.WaitForCompletionRef(ctx, auditingClient.Client); err != nil {
return fmt.Errorf("waiting for creation of SQL Server %q Blob Auditing Policies(Resource Group %q): %+v", name, resGroup, err)
return fmt.Errorf("waiting for creation of SQL Server %q Blob Auditing Policies(Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

@github-actions github-actions bot added size/M and removed size/S labels Aug 26, 2021
@catriona-m
Copy link
Member Author

Hi @catriona-m, this is looking great 👍

I made a couple of suggestions (the same thing in a few places) - the main one is that we can omit the Get request after creating/updating the resource since we already have the ID, and the other is making use of the String() method of the id struct to tidy up the error message strings.

If we can add those in, this should be good to merge 🚀

Thanks @manicminer, think I got them all!

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.

Thanks @catriona-m - LGTM 🏗️

@katbyte katbyte added refactor service/mssql Microsoft SQL Server labels Aug 27, 2021
@katbyte katbyte modified the milestones: v2.74.0, v2.75.0 Aug 27, 2021
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

+1 LGTM 🎸

@catriona-m catriona-m merged commit 12f3dc0 into main Aug 27, 2021
@catriona-m catriona-m deleted the cm/mssql_parser_update branch August 27, 2021 10:33
catriona-m added a commit that referenced this pull request Aug 27, 2021
@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This functionality has been released in v2.75.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Oct 3, 2021

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants