-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Conversation
Tests passing
|
storageAccountName := d.Get("storage_account_name").(string) | ||
id := strings.Split(d.Id(), "/") | ||
name := id[0] | ||
resourceGroupName := id[1] |
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.
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("") |
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 wants a return nil
here
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.
Done
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.
otherwise LGTM 👍
|
||
return resourceArmStorageShareRead(d, meta) | ||
} | ||
|
||
func resourceArmStorageShareExists(d *schema.ResourceData, meta interface{}) (bool, error) { |
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.
I think this method can be removed?
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.
Done
|
||
```shell | ||
terraform import azurerm_storage_share.testShare storageShareName/resourceGroupName/storageAccoutName | ||
``` |
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.
can we add -> **NOTE:** This identifier is unique to Terraform
below this
azurerm/validators.go
Outdated
@@ -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) { |
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.
since this is the only place it's used, can we move this back into the share resource?
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.
Done
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, |
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.
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)
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.
Done
armClient := meta.(*ArmClient) | ||
ctx := armClient.StopContext | ||
|
||
id := strings.Split(d.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.
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")
}
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.
Done
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! |
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.