diff --git a/helpers/azure/deprecated.go b/helpers/azure/deprecated.go deleted file mode 100644 index c3b2ed21a2ef..000000000000 --- a/helpers/azure/deprecated.go +++ /dev/null @@ -1,22 +0,0 @@ -package azure - -import ( - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" -) - -// shared schema -func MergeSchema(a map[string]*pluginsdk.Schema, b map[string]*pluginsdk.Schema) map[string]*pluginsdk.Schema { - // TODO: Deprecate and remove this - - s := map[string]*pluginsdk.Schema{} - - for k, v := range a { - s[k] = v - } - - for k, v := range b { - s[k] = v - } - - return s -} diff --git a/helpers/azure/sku.go b/helpers/azure/sku.go index f804cf90b3b1..09c3fb1625f4 100644 --- a/helpers/azure/sku.go +++ b/helpers/azure/sku.go @@ -4,9 +4,6 @@ import ( "fmt" "strconv" "strings" - - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-07-01/compute" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func SplitSku(sku string) (string, int32, error) { @@ -23,50 +20,3 @@ func SplitSku(sku string) (string, int32, error) { return skuParts[0], int32(capacity), nil } - -func ExpandOrchestratedVirtualMachineScaleSetSku(input string, capacity int) (*compute.Sku, error) { - skuParts := strings.Split(input, "_") - - if len(skuParts) < 2 || strings.Contains(input, "__") || strings.Contains(input, " ") { - return nil, fmt.Errorf("'sku_name'(%q) is not formatted properly.", input) - } - - sku := &compute.Sku{ - Name: utils.String(input), - Capacity: utils.Int64(int64(capacity)), - Tier: utils.String("Standard"), - } - - return sku, nil -} - -func FlattenOrchestratedVirtualMachineScaleSetSku(input *compute.Sku) (*string, error) { - var skuName string - if input != nil && input.Name != nil { - if strings.HasPrefix(strings.ToLower(*input.Name), "standard") { - skuName = *input.Name - } else { - skuName = fmt.Sprintf("Standard_%s", *input.Name) - } - - return &skuName, nil - } - - return nil, fmt.Errorf("Sku struct 'name' is nil") -} - -func ValidateOrchestratedVirtualMachineScaleSetSku(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - skuParts := strings.Split(v, "_") - - if len(skuParts) < 2 || strings.Contains(v, "__") || strings.Contains(v, " ") { - errors = append(errors, fmt.Errorf("%q(%q) is not formatted properly.", key, v)) - } - - return -} diff --git a/helpers/suppress/string.go b/helpers/suppress/string.go deleted file mode 100644 index ac97d12363bf..000000000000 --- a/helpers/suppress/string.go +++ /dev/null @@ -1,11 +0,0 @@ -package suppress - -import ( - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" -) - -// Deprecated: has been moved to internal and will be removed sooner then later -func CaseDifference(k, old, new string, d *pluginsdk.ResourceData) bool { - return suppress.CaseDifference(k, old, new, d) -} diff --git a/internal/azuresdkhacks/notes.go b/internal/azuresdkhacks/notes.go deleted file mode 100644 index 55ede0cb2222..000000000000 --- a/internal/azuresdkhacks/notes.go +++ /dev/null @@ -1,15 +0,0 @@ -package azuresdkhacks - -// There's a functional difference that exists between the Azure SDK for Go and Azure Resource Manager API -// where when performing a delta update unchanged fields are omitted from the response when they could -// also have a legitimate value of `null` (to remove/disable a sub-block). -// -// Ultimately the Azure SDK for Go has opted to serialize structs with `json:"name,omitempty"` which -// means that this value will be omitted if nil to allow for delta updates - however this means there's -// no means of removing/resetting a value of a nested object once provided since a `nil` object will be -// reset -// -// As such this set of well intentioned hacks is intended to force this behaviour where necessary. -// -// It's worth noting that these hacks are a last resort and the Swagger/API/SDK should almost always be -// fixed instead. diff --git a/internal/services/apimanagement/api_management_identity_provider_google_resource.go b/internal/services/apimanagement/api_management_identity_provider_google_resource.go index 92ff77504194..d4cf8f160793 100644 --- a/internal/services/apimanagement/api_management_identity_provider_google_resource.go +++ b/internal/services/apimanagement/api_management_identity_provider_google_resource.go @@ -8,10 +8,10 @@ import ( "github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2021-08-01/apimanagement" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" - "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/schemaz" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" diff --git a/helpers/validate/google.go b/internal/services/apimanagement/validate/google_client_id.go similarity index 100% rename from helpers/validate/google.go rename to internal/services/apimanagement/validate/google_client_id.go diff --git a/helpers/validate/google_test.go b/internal/services/apimanagement/validate/google_client_id_test.go similarity index 100% rename from helpers/validate/google_test.go rename to internal/services/apimanagement/validate/google_client_id_test.go diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go index bac6247523b0..9c4625c98322 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set_resource.go @@ -81,7 +81,7 @@ func resourceOrchestratedVirtualMachineScaleSet() *pluginsdk.Resource { "sku_name": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: azure.ValidateOrchestratedVirtualMachineScaleSetSku, + ValidateFunc: computeValidate.OrchestratedVirtualMachineScaleSetSku, }, "os_profile": OrchestratedVirtualMachineScaleSetOSProfileSchema(), @@ -281,7 +281,7 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData, instances := d.Get("instances").(int) if v, ok := d.GetOk("sku_name"); ok { isLegacy = false - sku, err := azure.ExpandOrchestratedVirtualMachineScaleSetSku(v.(string), instances) + sku, err := expandOrchestratedVirtualMachineScaleSetSku(v.(string), instances) if err != nil { return fmt.Errorf("expanding 'sku_name': %+v", err) } @@ -888,7 +888,7 @@ func resourceOrchestratedVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData, if d.HasChange("sku_name") { updateInstances = true - sku, err = azure.ExpandOrchestratedVirtualMachineScaleSetSku(d.Get("sku_name").(string), instances) + sku, err = expandOrchestratedVirtualMachineScaleSetSku(d.Get("sku_name").(string), instances) if err != nil { return err } @@ -988,7 +988,7 @@ func resourceOrchestratedVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, m var skuName *string var instances int if resp.Sku != nil { - skuName, err = azure.FlattenOrchestratedVirtualMachineScaleSetSku(resp.Sku) + skuName, err = flattenOrchestratedVirtualMachineScaleSetSku(resp.Sku) if err != nil || skuName == nil { return fmt.Errorf("setting `sku_name`: %+v", err) } @@ -1181,3 +1181,34 @@ func resourceOrchestratedVirtualMachineScaleSetDelete(d *pluginsdk.ResourceData, return nil } + +func expandOrchestratedVirtualMachineScaleSetSku(input string, capacity int) (*compute.Sku, error) { + skuParts := strings.Split(input, "_") + + if len(skuParts) < 2 || strings.Contains(input, "__") || strings.Contains(input, " ") { + return nil, fmt.Errorf("'sku_name'(%q) is not formatted properly.", input) + } + + sku := &compute.Sku{ + Name: utils.String(input), + Capacity: utils.Int64(int64(capacity)), + Tier: utils.String("Standard"), + } + + return sku, nil +} + +func flattenOrchestratedVirtualMachineScaleSetSku(input *compute.Sku) (*string, error) { + var skuName string + if input != nil && input.Name != nil { + if strings.HasPrefix(strings.ToLower(*input.Name), "standard") { + skuName = *input.Name + } else { + skuName = fmt.Sprintf("Standard_%s", *input.Name) + } + + return &skuName, nil + } + + return nil, fmt.Errorf("Sku struct 'name' is nil") +} diff --git a/utils/ssh_key.go b/internal/services/compute/ssh_key.go similarity index 85% rename from utils/ssh_key.go rename to internal/services/compute/ssh_key.go index 002844eea4a6..38030ad87c25 100644 --- a/utils/ssh_key.go +++ b/internal/services/compute/ssh_key.go @@ -1,8 +1,10 @@ -package utils +package compute import ( "fmt" "strings" + + "github.com/hashicorp/terraform-provider-azurerm/utils" ) // NormalizeSSHKey attempts to remove invalid formatting and line breaks that can be present in some cases @@ -24,5 +26,5 @@ func NormalizeSSHKey(input string) (*string, error) { normalised := strings.Join(lines, "") - return String(normalised), nil + return utils.String(normalised), nil } diff --git a/utils/ssh_key_test.go b/internal/services/compute/ssh_key_test.go similarity index 99% rename from utils/ssh_key_test.go rename to internal/services/compute/ssh_key_test.go index 137dc9fbd4b2..2202607dbe78 100644 --- a/utils/ssh_key_test.go +++ b/internal/services/compute/ssh_key_test.go @@ -1,4 +1,4 @@ -package utils +package compute import "testing" diff --git a/internal/services/compute/ssh_keys.go b/internal/services/compute/ssh_keys.go index 5a754c22bb3e..c1688708ddec 100644 --- a/internal/services/compute/ssh_keys.go +++ b/internal/services/compute/ssh_keys.go @@ -115,13 +115,13 @@ func parseUsernameFromAuthorizedKeysPath(input string) *string { } func SSHKeyDiffSuppress(_, old, new string, _ *pluginsdk.ResourceData) bool { - oldNormalized, err := utils.NormalizeSSHKey(old) + oldNormalized, err := NormalizeSSHKey(old) if err != nil { log.Printf("[DEBUG] error normalising ssh key %q: %+v", old, err) return false } - newNormalized, err := utils.NormalizeSSHKey(new) + newNormalized, err := NormalizeSSHKey(new) if err != nil { log.Printf("[DEBUG] error normalising ssh key %q: %+v", new, err) return false @@ -138,7 +138,7 @@ func SSHKeySchemaHash(v interface{}) int { var buf bytes.Buffer if m, ok := v.(map[string]interface{}); ok { - normalisedKey, err := utils.NormalizeSSHKey(m["public_key"].(string)) + normalisedKey, err := NormalizeSSHKey(m["public_key"].(string)) if err != nil { log.Printf("[DEBUG] error normalising ssh key %q: %+v", m["public_key"].(string), err) } diff --git a/internal/services/compute/ssh_public_key_data_source.go b/internal/services/compute/ssh_public_key_data_source.go index d8f5cd8f9161..90eb7e0986b3 100644 --- a/internal/services/compute/ssh_public_key_data_source.go +++ b/internal/services/compute/ssh_public_key_data_source.go @@ -68,7 +68,7 @@ func dataSourceSshPublicKeyRead(d *pluginsdk.ResourceData, meta interface{}) err var publicKey *string if props := resp.SSHPublicKeyResourceProperties; props.PublicKey != nil { - publicKey, err = utils.NormalizeSSHKey(*props.PublicKey) + publicKey, err = NormalizeSSHKey(*props.PublicKey) if err != nil { return fmt.Errorf("normalising public key: %+v", err) } diff --git a/internal/services/compute/validate/orchestrated_vmss_sku.go b/internal/services/compute/validate/orchestrated_vmss_sku.go new file mode 100644 index 000000000000..649a04242468 --- /dev/null +++ b/internal/services/compute/validate/orchestrated_vmss_sku.go @@ -0,0 +1,22 @@ +package validate + +import ( + "fmt" + "strings" +) + +func OrchestratedVirtualMachineScaleSetSku(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + skuParts := strings.Split(v, "_") + + if len(skuParts) < 2 || strings.Contains(v, "__") || strings.Contains(v, " ") { + errors = append(errors, fmt.Errorf("%q(%q) is not formatted properly.", key, v)) + } + + return +} diff --git a/internal/services/dns/dns_aaaa_record_resource.go b/internal/services/dns/dns_aaaa_record_resource.go index 1e73a6f6c727..c8932efd587a 100644 --- a/internal/services/dns/dns_aaaa_record_resource.go +++ b/internal/services/dns/dns_aaaa_record_resource.go @@ -205,7 +205,7 @@ func expandAzureRmDnsAaaaRecords(input []interface{}) *[]dns.AaaaRecord { records := make([]dns.AaaaRecord, len(input)) for i, v := range input { - ipv6 := utils.NormalizeIPv6Address(v) + ipv6 := NormalizeIPv6Address(v) records[i] = dns.AaaaRecord{ Ipv6Address: &ipv6, } @@ -225,7 +225,7 @@ func flattenAzureRmDnsAaaaRecords(records *[]dns.AaaaRecord) []string { continue } - results = append(results, utils.NormalizeIPv6Address(*record.Ipv6Address)) + results = append(results, NormalizeIPv6Address(*record.Ipv6Address)) } return results } diff --git a/utils/network.go b/internal/services/dns/ipv6_address.go similarity index 93% rename from utils/network.go rename to internal/services/dns/ipv6_address.go index e939c6754407..dc17613a6375 100644 --- a/utils/network.go +++ b/internal/services/dns/ipv6_address.go @@ -1,4 +1,4 @@ -package utils +package dns import "net" diff --git a/utils/network_test.go b/internal/services/dns/ipv6_address_test.go similarity index 98% rename from utils/network_test.go rename to internal/services/dns/ipv6_address_test.go index fe809c31f359..3ef0f21a4c45 100644 --- a/utils/network_test.go +++ b/internal/services/dns/ipv6_address_test.go @@ -1,4 +1,4 @@ -package utils +package dns import ( "testing" diff --git a/internal/services/eventhub/helpers.go b/internal/services/eventhub/helpers.go index 0c4219fa0442..e37259cadd2e 100644 --- a/internal/services/eventhub/helpers.go +++ b/internal/services/eventhub/helpers.go @@ -4,67 +4,58 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) func eventHubAuthorizationRuleSchemaFrom(s map[string]*pluginsdk.Schema) map[string]*pluginsdk.Schema { - authSchema := map[string]*pluginsdk.Schema{ - "listen": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "manage": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "primary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string_alias": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string_alias": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, + s["listen"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["manage"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["primary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["primary_connection_string_alias"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["primary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_connection_string_alias"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } - "secondary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, + s["secondary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } - "send": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, + s["send"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, } - return azure.MergeSchema(s, authSchema) + return s } func eventHubAuthorizationRuleCustomizeDiff(ctx context.Context, d *pluginsdk.ResourceDiff, _ interface{}) error { diff --git a/internal/azuresdkhacks/network_interface.go b/internal/services/network/azuresdkhacks/network_interface.go similarity index 98% rename from internal/azuresdkhacks/network_interface.go rename to internal/services/network/azuresdkhacks/network_interface.go index a841c3da0e43..1906900638d4 100644 --- a/internal/azuresdkhacks/network_interface.go +++ b/internal/services/network/azuresdkhacks/network_interface.go @@ -11,8 +11,6 @@ import ( "github.com/Azure/go-autorest/autorest" ) -// TODO: move this into the network package - // UpdateNetworkInterfaceAllowingRemovalOfNSG patches our way around a design flaw in the Azure // Resource Manager API <-> Azure SDK for Go where it's not possible to remove a Network Security Group func UpdateNetworkInterfaceAllowingRemovalOfNSG(ctx context.Context, client *network.InterfacesClient, resourceGroupName string, networkInterfaceName string, parameters network.Interface) (result network.InterfacesCreateOrUpdateFuture, err error) { diff --git a/internal/services/network/network_interface_network_security_group_association_resource.go b/internal/services/network/network_interface_network_security_group_association_resource.go index 7836bea87a1e..078ce01f233f 100644 --- a/internal/services/network/network_interface_network_security_group_association_resource.go +++ b/internal/services/network/network_interface_network_security_group_association_resource.go @@ -6,10 +6,11 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/azuresdkhacks" + "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-05-01/network" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" - "github.com/hashicorp/terraform-provider-azurerm/internal/azuresdkhacks" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" diff --git a/internal/services/network/network_interface_network_security_group_association_resource_test.go b/internal/services/network/network_interface_network_security_group_association_resource_test.go index 62a1ceb1b6e8..200e44caa30e 100644 --- a/internal/services/network/network_interface_network_security_group_association_resource_test.go +++ b/internal/services/network/network_interface_network_security_group_association_resource_test.go @@ -6,9 +6,10 @@ import ( "strings" "testing" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/azuresdkhacks" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" - "github.com/hashicorp/terraform-provider-azurerm/internal/azuresdkhacks" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" diff --git a/internal/services/relay/internal.go b/internal/services/relay/internal.go index f5326837f71d..2399cc6b2c5d 100644 --- a/internal/services/relay/internal.go +++ b/internal/services/relay/internal.go @@ -5,57 +5,48 @@ import ( "fmt" "log" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay/sdk/2017-04-01/hybridconnections" "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay/sdk/2017-04-01/namespaces" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) func authorizationRuleSchemaFrom(s map[string]*pluginsdk.Schema) map[string]*pluginsdk.Schema { - authSchema := map[string]*pluginsdk.Schema{ - "listen": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "send": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "manage": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "primary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - } - return azure.MergeSchema(s, authSchema) + s["listen"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["send"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["manage"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["primary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["primary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + return s } func expandAuthorizationRuleRights(d *pluginsdk.ResourceData) []namespaces.AccessRights { diff --git a/internal/services/servicebus/internal.go b/internal/services/servicebus/internal.go index 3fb7ff5cb55b..22e15c42067f 100644 --- a/internal/services/servicebus/internal.go +++ b/internal/services/servicebus/internal.go @@ -8,7 +8,6 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -53,62 +52,52 @@ func flattenAuthorizationRuleRights(rights *[]servicebus.AccessRights) (listen, } func authorizationRuleSchemaFrom(s map[string]*pluginsdk.Schema) map[string]*pluginsdk.Schema { - authSchema := map[string]*pluginsdk.Schema{ - "listen": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "send": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "manage": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, - - "primary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_key": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string_alias": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string_alias": { - Type: pluginsdk.TypeString, - Computed: true, - Sensitive: true, - }, + s["listen"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["send"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["manage"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + } + s["primary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["primary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_key"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_connection_string"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["primary_connection_string_alias"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, + } + s["secondary_connection_string_alias"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Computed: true, + Sensitive: true, } - return azure.MergeSchema(s, authSchema) + return s } func authorizationRuleCustomizeDiff(ctx context.Context, d *pluginsdk.ResourceDiff, _ interface{}) error { diff --git a/internal/tf/suppress/string.go b/internal/tf/suppress/string.go index cb19d0d22766..02e1493179b2 100644 --- a/internal/tf/suppress/string.go +++ b/internal/tf/suppress/string.go @@ -13,7 +13,7 @@ func CaseDifference(_, old, new string, _ *schema.ResourceData) bool { // CaseDifferenceV2Only only suppress case difference for v2.0. func CaseDifferenceV2Only(_, old, new string, _ *schema.ResourceData) bool { - if features.ThreePointOh() { + if features.ThreePointOhBeta() { return old == new } return strings.EqualFold(old, new)