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

Storage Share Quota and Import Support #1650

Merged
merged 5 commits into from
Jul 26, 2018
Merged

Storage Share Quota and Import Support #1650

merged 5 commits into from
Jul 26, 2018

Conversation

mbfrahry
Copy link
Member

This PR allows quota to be updated. Import is now supported. General cleanup has also been done with moving the validation functions to their respective validation and validation test files.

@mbfrahry mbfrahry requested a review from a team July 26, 2018 06:11
@mbfrahry
Copy link
Member Author

Tests passing

=== RUN   TestAccAzureRMStorageShare_basic
--- PASS: TestAccAzureRMStorageShare_basic (80.86s)
=== RUN   TestAccAzureRMStorageShare_disappears
--- PASS: TestAccAzureRMStorageShare_disappears (86.22s)
=== RUN   TestAccAzureRMStorageShare_updateQuota
--- PASS: TestAccAzureRMStorageShare_updateQuota (98.15s)

storageAccountName := d.Get("storage_account_name").(string)
id := strings.Split(d.Id(), "/")
name := id[0]
resourceGroupName := id[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed on Slack - there's a crash here until we have a state migration for the ID switch

// Exists already removed this from state
return nil
log.Printf("[INFO] Share %q no longer exists, removing from state...", name)
d.SetId("")
Copy link
Contributor

Choose a reason for hiding this comment

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

this wants a return nil here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

otherwise LGTM 👍


return resourceArmStorageShareRead(d, meta)
}

func resourceArmStorageShareExists(d *schema.ResourceData, meta interface{}) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method can be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


```shell
terraform import azurerm_storage_share.testShare storageShareName/resourceGroupName/storageAccoutName
```
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add -> **NOTE:** This identifier is unique to Terraform below this

@@ -246,3 +246,26 @@ func validateFilePath() schema.SchemaValidateFunc {
return
}
}

//Following the naming convention as laid out in the docs https://msdn.microsoft.com/library/azure/dn167011.aspx
func validateArmStorageShareName(v interface{}, k string) (ws []string, errors []error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is the only place it's used, can we move this back into the share resource?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove the Imports from this test (since they're covered by the Basic test above; in general we don't Import test updates since they're covered elsewhere)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

armClient := meta.(*ArmClient)
ctx := armClient.StopContext

id := strings.Split(d.Id(), "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a potential crash in these few lines if the segments aren't correct - as such we probably want to add below this:

if len(id) != 3 {
  return fmt.Errorf("ID was not in the expected format - expected `{name}/{resourceGroup}/{storageAccountName}` got %q")
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@tombuildsstuff tombuildsstuff added this to the 1.12.0 milestone Jul 26, 2018
@mbfrahry mbfrahry merged commit ba51b76 into master Jul 26, 2018
@mbfrahry mbfrahry deleted the f-share-quota branch July 26, 2018 15:01
@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants