From e817551e111a4015b1a4fd419aea16a04c5c58d4 Mon Sep 17 00:00:00 2001 From: Alex Wilcox Date: Fri, 19 Aug 2022 23:56:36 +0100 Subject: [PATCH] Add SMB multichannel --- .../storage/storage_account_resource.go | 23 ++++++++- .../storage/storage_account_resource_test.go | 48 +++++++++++++++++++ website/docs/r/storage_account.html.markdown | 2 + 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index d88f5c546d85..01b7dfdc87ff 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -660,6 +660,11 @@ func resourceStorageAccount() *pluginsdk.Resource { }, false), }, }, + "multichannel_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, }, }, }, @@ -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), + }, } } @@ -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)), + }, } } @@ -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{}{ @@ -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, }, } } diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index e52b9eacf809..186bccedf6e1 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -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 { @@ -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) +} diff --git a/website/docs/r/storage_account.html.markdown b/website/docs/r/storage_account.html.markdown index 140b4fd2c48e..8465209264c0 100644 --- a/website/docs/r/storage_account.html.markdown +++ b/website/docs/r/storage_account.html.markdown @@ -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