Skip to content

Commit

Permalink
Flatten blob properties schema...
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon committed Sep 21, 2024
1 parent 79e63bb commit e448212
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 62 deletions.
31 changes: 30 additions & 1 deletion internal/services/storage/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sort"

"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01/blobservice"
"github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01/storageaccounts"
)

Expand All @@ -20,7 +21,7 @@ func sortedKeysFromSlice(input map[storageaccounts.Kind]struct{}) []string {
return keys
}

func validateExistingModel(input *storageaccounts.StorageAccount, id *commonids.StorageAccountId) error {
func validateStorageAccountModel(input *storageaccounts.StorageAccount, id *commonids.StorageAccountId) error {
if input == nil {
return fmt.Errorf("retrieving %s: `model` was nil", id)
}
Expand All @@ -39,3 +40,31 @@ func validateExistingModel(input *storageaccounts.StorageAccount, id *commonids.

return nil
}

func validateBlobPropertiesModel(input *blobservice.BlobServiceProperties, id *commonids.StorageAccountId) error {
if input == nil {
return fmt.Errorf("retrieving %s: `model` was nil", id)
}

if input.Id == nil {
return fmt.Errorf("retrieving %s: `model.Id` was nil", id)
}

if input.Name == nil {
return fmt.Errorf("retrieving %s: `model.Name` was nil", id)
}

if input.Properties == nil {
return fmt.Errorf("retrieving %s: `model.Properties` was nil", id)
}

if input.Sku == nil {
return fmt.Errorf("retrieving %s: `model.Sku` was nil", id)
}

if input.Type == nil {
return fmt.Errorf("retrieving %s: `model.Type` was nil", id)
}

return nil
}
294 changes: 259 additions & 35 deletions internal/services/storage/storage_account_blob_properties_resource.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func resourceStorageAccountQueuePropertiesCreate(d *pluginsdk.ResourceData, meta
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down Expand Up @@ -253,7 +253,7 @@ func resourceStorageAccountQueuePropertiesUpdate(d *pluginsdk.ResourceData, meta
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func resourceStorageAccountSharePropertiesCreate(d *pluginsdk.ResourceData, meta
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down Expand Up @@ -252,7 +252,7 @@ func resourceStorageAccountSharePropertiesUpdate(d *pluginsdk.ResourceData, meta
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down Expand Up @@ -313,7 +313,7 @@ func resourceStorageAccountSharePropertiesRead(d *pluginsdk.ResourceData, meta i
}

model := resp.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down Expand Up @@ -372,7 +372,7 @@ func resourceStorageAccountSharePropertiesDelete(d *pluginsdk.ResourceData, meta
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func resourceStorageAccountStaticWebSitePropertiesCreate(d *pluginsdk.ResourceDa
// TODO: Add Import error supported for this resource...

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down Expand Up @@ -183,7 +183,7 @@ func resourceStorageAccountStaticWebSitePropertiesUpdate(d *pluginsdk.ResourceDa
}

model := existing.Model
if err := validateExistingModel(model, id); err != nil {
if err := validateStorageAccountModel(model, id); err != nil {
return err
}

Expand Down
22 changes: 7 additions & 15 deletions website/docs/r/storage_account_blob_properties.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,22 @@ resource "azurerm_storage_account" "example" {
resource "azurerm_storage_account_blob_properties" "example" {
storage_account_id = azurerm_storage_account.example.id
properties {
delete_retention_policy {}
delete_retention_policy {}
restore_policy {
days = 6
}
versioning_enabled = true
change_feed_enabled = true
restore_policy {
days = 6
}
versioning_enabled = true
change_feed_enabled = true
}
```

## Argument Reference

The following arguments are supported:

* `storage_account_id` - (Required) Specifies the resource id of the storage account.

* `properties` - (Required) A `properties` block as defined below.

---

A `properties` block supports the following:
* `storage_account_id` - (Required) Specifies the resource id of the storage account. Changing this forces a new resource to be created.

* `cors_rule` - (Optional) A `cors_rule` block as defined below.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ resource "azurerm_storage_account_queue_properties" "example" {

The following arguments are supported:

* `storage_account_id` - (Required) Specifies the resource id of the storage account.
* `storage_account_id` - (Required) Specifies the resource id of the storage account. Changing this forces a new resource to be created.

* `properties` - (Required) A `properties` block as defined below.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "azurerm_storage_account_share_properties" "example" {

The following arguments are supported:

* `storage_account_id` - (Required) Specifies the resource id of the storage account.
* `storage_account_id` - (Required) Specifies the resource id of the storage account. Changing this forces a new resource to be created.

* `cors_rule` - (Optional) A `cors_rule` block as defined below.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "azurerm_storage_account_static_website_properties" "example" {

The following arguments are supported:

* `storage_account_id` - (Required) Specifies the resource id of the storage account.
* `storage_account_id` - (Required) Specifies the resource id of the storage account. Changing this forces a new resource to be created.

* `index_document` - (Optional) The webpage that Azure Storage serves for requests to the root of a website or any subfolder (e.g., `index.html`). The value is case-sensitive.

Expand Down

0 comments on commit e448212

Please sign in to comment.