Skip to content

Commit

Permalink
Add SMB multichannel
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwilcox9 committed Aug 19, 2022
1 parent 6be2754 commit e817551
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
23 changes: 22 additions & 1 deletion internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ func resourceStorageAccount() *pluginsdk.Resource {
}, false),
},
},
"multichannel_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand Down Expand Up @@ -2452,6 +2457,9 @@ func expandSharePropertiesSMB(input []interface{}) *storage.SmbSetting {
AuthenticationMethods: utils.String(""),
KerberosTicketEncryption: utils.String(""),
ChannelEncryption: utils.String(""),
Multichannel: &storage.Multichannel{
Enabled: utils.Bool(false),
},
}
}

Expand All @@ -2462,6 +2470,9 @@ func expandSharePropertiesSMB(input []interface{}) *storage.SmbSetting {
AuthenticationMethods: utils.ExpandStringSliceWithDelimiter(v["authentication_types"].(*pluginsdk.Set).List(), ";"),
KerberosTicketEncryption: utils.ExpandStringSliceWithDelimiter(v["kerberos_ticket_encryption_type"].(*pluginsdk.Set).List(), ";"),
ChannelEncryption: utils.ExpandStringSliceWithDelimiter(v["channel_encryption_type"].(*pluginsdk.Set).List(), ";"),
Multichannel: &storage.Multichannel{
Enabled: utils.Bool(v["multichannel_enabled"].(bool)),
},
}
}

Expand Down Expand Up @@ -3072,8 +3083,17 @@ func flattenedSharePropertiesSMB(input *storage.SmbSetting) []interface{} {
channelEncryption = utils.FlattenStringSliceWithDelimiter(input.ChannelEncryption, ";")
}

multichannelEnabled := false
if input.Multichannel != nil && input.Multichannel.Enabled != nil {
multichannelEnabled = *input.Multichannel.Enabled
}

if len(versions) == 0 && len(authenticationMethods) == 0 && len(kerberosTicketEncryption) == 0 && len(channelEncryption) == 0 {
return []interface{}{}
return []interface{}{
map[string]interface{}{
"multichannel_enabled": multichannelEnabled,
},
}
}

return []interface{}{
Expand All @@ -3082,6 +3102,7 @@ func flattenedSharePropertiesSMB(input *storage.SmbSetting) []interface{} {
"authentication_types": authenticationMethods,
"kerberos_ticket_encryption_type": kerberosTicketEncryption,
"channel_encryption_type": channelEncryption,
"multichannel_enabled": multichannelEnabled,
},
}
}
Expand Down
48 changes: 48 additions & 0 deletions internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,28 @@ func TestAccStorageAccount_edgeZone(t *testing.T) {
})
}

func TestAccStorageAccount_smbMultichannel(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.smbMultichannel(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.smbMultichannel(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (r StorageAccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.StorageAccountID(state.ID)
if err != nil {
Expand Down Expand Up @@ -3789,3 +3811,29 @@ resource "azurerm_storage_account" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) smbMultichannel(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-storage-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Premium"
account_kind = "FileStorage"
account_replication_type = "ZRS"
share_properties {
smb {
multichannel_enabled = %t
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, enabled)
}
2 changes: 2 additions & 0 deletions website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ A `smb` block supports the following:

* `channel_encryption_type` - (Optional) A set of SMB channel encryption. Possible values are `AES-128-CCM`, `AES-128-GCM`, and `AES-256-GCM`.

* `multichannel_enabled` - (Optional) Indicates whether multichannel is enabled. Defaults to `false`.

---

## Attributes Reference
Expand Down

0 comments on commit e817551

Please sign in to comment.