From 936101b8f5abb4347e09cef5a7c4eaccfcffdc12 Mon Sep 17 00:00:00 2001 From: kt Date: Thu, 8 Aug 2019 07:06:06 -0700 Subject: [PATCH 1/2] provider: misc golang inspection cleanup --- azurerm/data_factory.go | 2 +- azurerm/helpers/azure/automation_variable.go | 42 -------------- azurerm/helpers/azure/batch_pool.go | 4 +- azurerm/helpers/azure/hdinsight.go | 2 +- azurerm/helpers/azure/location.go | 2 +- azurerm/helpers/azure/sender.go | 57 ------------------- azurerm/helpers/validate/mariadb.go | 4 +- azurerm/internal/services/storage/metadata.go | 2 +- azurerm/resource_arm_application_gateway.go | 2 +- azurerm/resource_arm_batch_account_test.go | 5 +- azurerm/resource_arm_container_group.go | 4 +- azurerm/resource_arm_iot_dps.go | 2 +- azurerm/resource_arm_logic_app_action_http.go | 10 ++-- ...urce_arm_logic_app_trigger_http_request.go | 10 ++-- azurerm/resource_arm_metric_alertrule_test.go | 5 +- ...ource_arm_monitor_metric_alertrule_test.go | 5 +- .../resource_arm_policy_definition_test.go | 5 +- azurerm/resource_arm_sql_server.go | 4 +- azurerm/resource_arm_storage_blob.go | 2 +- azurerm/resource_arm_storage_share.go | 3 +- .../resource_arm_storage_share_migration.go | 2 +- azurerm/resource_arm_storage_table_test.go | 23 +++----- 22 files changed, 43 insertions(+), 154 deletions(-) delete mode 100644 azurerm/helpers/azure/automation_variable.go delete mode 100644 azurerm/helpers/azure/sender.go diff --git a/azurerm/data_factory.go b/azurerm/data_factory.go index ac2d9c7be8b4..c6bd3b394f04 100644 --- a/azurerm/data_factory.go +++ b/azurerm/data_factory.go @@ -31,7 +31,7 @@ func expandDataFactoryLinkedServiceIntegrationRuntime(integrationRuntimeName str // Because the password isn't returned from the api in the connection string, we'll check all // but the password string and return true if they match. -func azureRmDataFactoryLinkedServiceConnectionStringDiff(k, old string, new string, d *schema.ResourceData) bool { +func azureRmDataFactoryLinkedServiceConnectionStringDiff(_, old string, new string, _ *schema.ResourceData) bool { oldSplit := strings.Split(strings.ToLower(old), ";") newSplit := strings.Split(strings.ToLower(new), ";") diff --git a/azurerm/helpers/azure/automation_variable.go b/azurerm/helpers/azure/automation_variable.go deleted file mode 100644 index 906b62c1b0ed..000000000000 --- a/azurerm/helpers/azure/automation_variable.go +++ /dev/null @@ -1,42 +0,0 @@ -package azure - -import ( - "fmt" - "regexp" - "strconv" - "time" -) - -func ParseAzureRmAutomationVariableValue(resource string, input *string) (interface{}, error) { - if input == nil { - if resource != "azurerm_automation_variable_null" { - return nil, fmt.Errorf("Expected value \"nil\" to be %q, actual type is \"azurerm_automation_variable_null\"", resource) - } - return nil, nil - } - - var value interface{} - var err error - actualResource := "Unknown" - datePattern := regexp.MustCompile(`"\\/Date\((-?[0-9]+)\)\\/"`) - matches := datePattern.FindStringSubmatch(*input) - - if len(matches) == 2 && matches[0] == *input { - if ticks, err := strconv.ParseInt(matches[1], 10, 64); err == nil { - value = time.Unix(ticks/1000, ticks%1000*1000000).In(time.UTC) - actualResource = "azurerm_automation_variable_datetime" - } - } else if value, err = strconv.Unquote(*input); err == nil { - actualResource = "azurerm_automation_variable_string" - } else if value, err = strconv.ParseBool(*input); err == nil { - actualResource = "azurerm_automation_variable_bool" - } else if value, err = strconv.ParseInt(*input, 10, 32); err == nil { - value = int32(value.(int64)) - actualResource = "azurerm_automation_variable_int" - } - - if actualResource != resource { - return nil, fmt.Errorf("Expected value %q to be %q, actual type is %q", *input, resource, actualResource) - } - return value, nil -} diff --git a/azurerm/helpers/azure/batch_pool.go b/azurerm/helpers/azure/batch_pool.go index 68a4fc00283c..8233618a8bf8 100644 --- a/azurerm/helpers/azure/batch_pool.go +++ b/azurerm/helpers/azure/batch_pool.go @@ -262,7 +262,7 @@ func ExpandBatchPoolContainerConfiguration(list []interface{}) (*batch.Container // ExpandBatchPoolCertificateReferences expands Batch pool certificate references func ExpandBatchPoolCertificateReferences(list []interface{}) (*[]batch.CertificateReference, error) { - result := []batch.CertificateReference{} + var result []batch.CertificateReference for _, tempItem := range list { item := tempItem.(map[string]interface{}) @@ -284,7 +284,7 @@ func expandBatchPoolCertificateReference(ref map[string]interface{}) (*batch.Cer storeLocation := ref["store_location"].(string) storeName := ref["store_name"].(string) visibilityRefs := ref["visibility"].(*schema.Set) - visibility := []batch.CertificateVisibility{} + var visibility []batch.CertificateVisibility if visibilityRefs != nil { for _, visibilityRef := range visibilityRefs.List() { visibility = append(visibility, batch.CertificateVisibility(visibilityRef.(string))) diff --git a/azurerm/helpers/azure/hdinsight.go b/azurerm/helpers/azure/hdinsight.go index 4388c80fef16..264f4efc168e 100644 --- a/azurerm/helpers/azure/hdinsight.go +++ b/azurerm/helpers/azure/hdinsight.go @@ -54,7 +54,7 @@ func SchemaHDInsightClusterVersion() *schema.Schema { } } -func hdinsightClusterVersionDiffSuppressFunc(k, old, new string, d *schema.ResourceData) bool { +func hdinsightClusterVersionDiffSuppressFunc(_, old, new string, _ *schema.ResourceData) bool { // `3.6` gets converted to `3.6.1000.67`; so let's just compare major/minor if possible o := strings.Split(old, ".") n := strings.Split(new, ".") diff --git a/azurerm/helpers/azure/location.go b/azurerm/helpers/azure/location.go index 6dcfa091af6a..64c6bb78732d 100644 --- a/azurerm/helpers/azure/location.go +++ b/azurerm/helpers/azure/location.go @@ -54,7 +54,7 @@ func NormalizeLocation(location interface{}) string { return strings.Replace(strings.ToLower(input), " ", "", -1) } -func SuppressLocationDiff(k, old, new string, d *schema.ResourceData) bool { +func SuppressLocationDiff(_, old, new string, _ *schema.ResourceData) bool { return NormalizeLocation(old) == NormalizeLocation(new) } diff --git a/azurerm/helpers/azure/sender.go b/azurerm/helpers/azure/sender.go deleted file mode 100644 index 901e0068d676..000000000000 --- a/azurerm/helpers/azure/sender.go +++ /dev/null @@ -1,57 +0,0 @@ -package azure - -import ( - "log" - "net/http" - "net/http/httputil" - - "github.com/Azure/go-autorest/autorest" -) - -func BuildSender() autorest.Sender { - return autorest.DecorateSender(&http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - }, - }, withRequestLogging()) -} - -func withRequestLogging() autorest.SendDecorator { - return func(s autorest.Sender) autorest.Sender { - return autorest.SenderFunc(func(r *http.Request) (*http.Response, error) { - // strip the authorization header prior to printing - authHeaderName := "Authorization" - auth := r.Header.Get(authHeaderName) - if auth != "" { - r.Header.Del(authHeaderName) - } - - // dump request to wire format - if dump, err := httputil.DumpRequestOut(r, true); err == nil { - log.Printf("[DEBUG] AzureRM Request: \n%s\n", dump) - } else { - // fallback to basic message - log.Printf("[DEBUG] AzureRM Request: %s to %s\n", r.Method, r.URL) - } - - // add the auth header back - if auth != "" { - r.Header.Add(authHeaderName, auth) - } - - resp, err := s.Do(r) - if resp != nil { - // dump response to wire format - if dump, err2 := httputil.DumpResponse(resp, true); err2 == nil { - log.Printf("[DEBUG] AzureRM Response for %s: \n%s\n", r.URL, dump) - } else { - // fallback to basic message - log.Printf("[DEBUG] AzureRM Response: %s for %s\n", resp.Status, r.URL) - } - } else { - log.Printf("[DEBUG] Request to %s completed with no response", r.URL) - } - return resp, err - }) - } -} diff --git a/azurerm/helpers/validate/mariadb.go b/azurerm/helpers/validate/mariadb.go index 38317d60c868..0cd951947bf6 100644 --- a/azurerm/helpers/validate/mariadb.go +++ b/azurerm/helpers/validate/mariadb.go @@ -5,7 +5,7 @@ import ( "regexp" ) -func MariaDBFirewallRuleName(v interface{}, k string) (warnings []string, errors []error) { +func MariaDBFirewallRuleName(v interface{}, _ string) (warnings []string, errors []error) { value := v.(string) // Firewall rule name can contain alphanumeric characters and hyphens and must be 1 - 128 characters long @@ -16,7 +16,7 @@ func MariaDBFirewallRuleName(v interface{}, k string) (warnings []string, errors return warnings, errors } -func MariaDBServerName(v interface{}, k string) (warnings []string, errors []error) { +func MariaDBServerName(v interface{}, _ string) (warnings []string, errors []error) { value := v.(string) // MariaDB server name can contain alphanumeric characters and hyphens and must be 3 - 63 characters long diff --git a/azurerm/internal/services/storage/metadata.go b/azurerm/internal/services/storage/metadata.go index 21bb982119aa..5d0bcfa78513 100644 --- a/azurerm/internal/services/storage/metadata.go +++ b/azurerm/internal/services/storage/metadata.go @@ -45,7 +45,7 @@ func FlattenMetaData(input map[string]string) map[string]interface{} { return output } -func validateMetaDataKeys(value interface{}, fieldName string) (warnings []string, errors []error) { +func validateMetaDataKeys(value interface{}, _ string) (warnings []string, errors []error) { v, ok := value.(map[string]interface{}) if !ok { return diff --git a/azurerm/resource_arm_application_gateway.go b/azurerm/resource_arm_application_gateway.go index bd46a0ce068d..44569b1f947e 100644 --- a/azurerm/resource_arm_application_gateway.go +++ b/azurerm/resource_arm_application_gateway.go @@ -2267,7 +2267,7 @@ func expandApplicationGatewayIPConfigurations(d *schema.ResourceData) (*[]networ // If we're creating the application gateway return the current gateway ip configuration. if len(oldVS) == 0 { - return &results, stopApplicationGateway + return &results, false } // The application gateway needs to be stopped if a gateway ip configuration is added or removed diff --git a/azurerm/resource_arm_batch_account_test.go b/azurerm/resource_arm_batch_account_test.go index 4efc25a770cc..f008df886043 100644 --- a/azurerm/resource_arm_batch_account_test.go +++ b/azurerm/resource_arm_batch_account_test.go @@ -138,9 +138,8 @@ func TestAccAzureRMBatchAccount_userSubscription(t *testing.T) { location := testLocation() tenantID := os.Getenv("ARM_TENANT_ID") - subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID") - config := testAccAzureRMBatchAccount_userSubscription(ri, rs, location, tenantID, subscriptionID) + config := testAccAzureRMBatchAccount_userSubscription(ri, rs, location, tenantID) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -299,7 +298,7 @@ resource "azurerm_batch_account" "test" { `, rInt, location, rString, rString) } -func testAccAzureRMBatchAccount_userSubscription(rInt int, batchAccountSuffix string, location string, tenantID string, subscriptionID string) string { +func testAccAzureRMBatchAccount_userSubscription(rInt int, batchAccountSuffix string, location string, tenantID string) string { return fmt.Sprintf(` data "azuread_service_principal" "test" { display_name = "Microsoft Azure Batch" diff --git a/azurerm/resource_arm_container_group.go b/azurerm/resource_arm_container_group.go index 366e207d9f61..9e05cd4140e1 100755 --- a/azurerm/resource_arm_container_group.go +++ b/azurerm/resource_arm_container_group.go @@ -523,7 +523,7 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err d.Set("location", azure.NormalizeLocation(*location)) } - if err := d.Set("identity", flattenContainerGroupIdentity(d, resp.Identity)); err != nil { + if err := d.Set("identity", flattenContainerGroupIdentity(resp.Identity)); err != nil { return fmt.Errorf("Error setting `identity`: %+v", err) } @@ -900,7 +900,7 @@ func expandContainerProbe(input interface{}) *containerinstance.ContainerProbe { return &probe } -func flattenContainerGroupIdentity(d *schema.ResourceData, identity *containerinstance.ContainerGroupIdentity) []interface{} { +func flattenContainerGroupIdentity(identity *containerinstance.ContainerGroupIdentity) []interface{} { if identity == nil { return make([]interface{}, 0) } diff --git a/azurerm/resource_arm_iot_dps.go b/azurerm/resource_arm_iot_dps.go index 68ded75b1271..e5c12471c532 100644 --- a/azurerm/resource_arm_iot_dps.go +++ b/azurerm/resource_arm_iot_dps.go @@ -306,7 +306,7 @@ func expandIoTDPSIoTHubs(input []interface{}) *[]iothub.DefinitionDescription { linkedHub := iothub.DefinitionDescription{ ConnectionString: utils.String(linkedHubConfig["connection_string"].(string)), AllocationWeight: utils.Int32(int32(linkedHubConfig["allocation_weight"].(int))), - ApplyAllocationPolicy: utils.Bool((linkedHubConfig["apply_allocation_policy"].(bool))), + ApplyAllocationPolicy: utils.Bool(linkedHubConfig["apply_allocation_policy"].(bool)), Location: utils.String(linkedHubConfig["location"].(string)), } diff --git a/azurerm/resource_arm_logic_app_action_http.go b/azurerm/resource_arm_logic_app_action_http.go index f98fdc9bbd92..2b922500f13a 100644 --- a/azurerm/resource_arm_logic_app_action_http.go +++ b/azurerm/resource_arm_logic_app_action_http.go @@ -40,11 +40,11 @@ func resourceArmLogicAppActionHTTP() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(http.MethodDelete), - string(http.MethodGet), - string(http.MethodPatch), - string(http.MethodPost), - string(http.MethodPut), + http.MethodDelete, + http.MethodGet, + http.MethodPatch, + http.MethodPost, + http.MethodPut, }, false), }, diff --git a/azurerm/resource_arm_logic_app_trigger_http_request.go b/azurerm/resource_arm_logic_app_trigger_http_request.go index 97b43d492eb8..dafb2128fe29 100644 --- a/azurerm/resource_arm_logic_app_trigger_http_request.go +++ b/azurerm/resource_arm_logic_app_trigger_http_request.go @@ -61,11 +61,11 @@ func resourceArmLogicAppTriggerHttpRequest() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringInSlice([]string{ - string(http.MethodDelete), - string(http.MethodGet), - string(http.MethodPatch), - string(http.MethodPost), - string(http.MethodPut), + http.MethodDelete, + http.MethodGet, + http.MethodPatch, + http.MethodPost, + http.MethodPut, }, false), }, diff --git a/azurerm/resource_arm_metric_alertrule_test.go b/azurerm/resource_arm_metric_alertrule_test.go index 1fece9470fc9..0d79dfe1e864 100644 --- a/azurerm/resource_arm_metric_alertrule_test.go +++ b/azurerm/resource_arm_metric_alertrule_test.go @@ -113,7 +113,6 @@ func TestAccAzureRMMetricAlertRule_requiresImport(t *testing.T) { resourceName := "azurerm_metric_alertrule.test" ri := tf.AccRandTimeInt() location := testLocation() - enabled := true resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -121,13 +120,13 @@ func TestAccAzureRMMetricAlertRule_requiresImport(t *testing.T) { CheckDestroy: testCheckAzureRMMetricAlertRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, location, enabled), + Config: testAccAzureRMMetricAlertRule_virtualMachineCpu(ri, location, true), Check: resource.ComposeTestCheckFunc( testCheckAzureRMMetricAlertRuleExists(resourceName), ), }, { - Config: testAccAzureRMMetricAlertRule_requiresImport(ri, location, enabled), + Config: testAccAzureRMMetricAlertRule_requiresImport(ri, location, true), ExpectError: testRequiresImportError("azurerm_metric_alertrule"), }, }, diff --git a/azurerm/resource_arm_monitor_metric_alertrule_test.go b/azurerm/resource_arm_monitor_metric_alertrule_test.go index b0feadac65f6..33ce0098436e 100644 --- a/azurerm/resource_arm_monitor_metric_alertrule_test.go +++ b/azurerm/resource_arm_monitor_metric_alertrule_test.go @@ -113,7 +113,6 @@ func TestAccAzureRMMonitorMetricAlertRule_requiresImport(t *testing.T) { resourceName := "azurerm_monitor_metric_alertrule.test" ri := tf.AccRandTimeInt() location := testLocation() - enabled := true resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -121,13 +120,13 @@ func TestAccAzureRMMonitorMetricAlertRule_requiresImport(t *testing.T) { CheckDestroy: testCheckAzureRMMonitorMetricAlertRuleDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMMonitorMetricAlertRule_virtualMachineCpu(ri, location, enabled), + Config: testAccAzureRMMonitorMetricAlertRule_virtualMachineCpu(ri, location, true), Check: resource.ComposeTestCheckFunc( testCheckAzureRMMonitorMetricAlertRuleExists(resourceName), ), }, { - Config: testAccAzureRMMonitorMetricAlertRule_requiresImport(ri, location, enabled), + Config: testAccAzureRMMonitorMetricAlertRule_requiresImport(ri, location, true), ExpectError: testRequiresImportError("azurerm_monitor_metric_alertrule"), }, }, diff --git a/azurerm/resource_arm_policy_definition_test.go b/azurerm/resource_arm_policy_definition_test.go index bd03c8675772..1c62888cc3f9 100644 --- a/azurerm/resource_arm_policy_definition_test.go +++ b/azurerm/resource_arm_policy_definition_test.go @@ -89,7 +89,6 @@ func TestAccAzureRMPolicyDefinition_computedMetadata(t *testing.T) { func TestAccAzureRMPolicyDefinitionAtMgmtGroup_basic(t *testing.T) { resourceName := "azurerm_policy_definition.test" - mgmtGroupName := "azurerm_management_group.test" ri := tf.AccRandTimeInt() @@ -101,7 +100,7 @@ func TestAccAzureRMPolicyDefinitionAtMgmtGroup_basic(t *testing.T) { { Config: testAzureRMPolicyDefinition_ManagementGroup(ri), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(resourceName, mgmtGroupName), + testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(resourceName), ), }, { @@ -113,7 +112,7 @@ func TestAccAzureRMPolicyDefinitionAtMgmtGroup_basic(t *testing.T) { }) } -func testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(policyName string, managementGroupName string) resource.TestCheckFunc { +func testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(policyName string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[policyName] if !ok { diff --git a/azurerm/resource_arm_sql_server.go b/azurerm/resource_arm_sql_server.go index fcc75df9f4dc..6bcf6497e60f 100644 --- a/azurerm/resource_arm_sql_server.go +++ b/azurerm/resource_arm_sql_server.go @@ -41,8 +41,8 @@ func resourceArmSqlServer() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string("2.0"), - string("12.0"), + "2.0", + "12.0", }, true), }, diff --git a/azurerm/resource_arm_storage_blob.go b/azurerm/resource_arm_storage_blob.go index 1c6d26c67054..ef1911c8a6ce 100644 --- a/azurerm/resource_arm_storage_blob.go +++ b/azurerm/resource_arm_storage_blob.go @@ -771,7 +771,7 @@ func expandStorageAccountBlobMetadata(d *schema.ResourceData) storage.BlobMetada for key, value := range blobMetadataRaw { blobMetadata[key] = value.(string) } - return storage.BlobMetadata(blobMetadata) + return blobMetadata } func flattenStorageAccountBlobMetadata(in storage.BlobMetadata) map[string]interface{} { diff --git a/azurerm/resource_arm_storage_share.go b/azurerm/resource_arm_storage_share.go index d0f2834ac733..82444c768320 100644 --- a/azurerm/resource_arm_storage_share.go +++ b/azurerm/resource_arm_storage_share.go @@ -313,8 +313,7 @@ func resourceArmStorageShareDelete(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error building File Share Client for Storage Account %q (Resource Group %q): %s", id.AccountName, *resourceGroup, err) } - deleteSnapshots := true - if _, err := client.Delete(ctx, id.AccountName, id.ShareName, deleteSnapshots); err != nil { + if _, err := client.Delete(ctx, id.AccountName, id.ShareName, true); err != nil { return fmt.Errorf("Error deleting File Share %q (Storage Account %q / Resource Group %q): %s", id.ShareName, id.AccountName, *resourceGroup, err) } diff --git a/azurerm/resource_arm_storage_share_migration.go b/azurerm/resource_arm_storage_share_migration.go index e73b132cd2b9..d4355c495133 100644 --- a/azurerm/resource_arm_storage_share_migration.go +++ b/azurerm/resource_arm_storage_share_migration.go @@ -41,7 +41,7 @@ func resourceStorageShareStateResourceV0V1() *schema.Resource { } } -func resourceStorageShareStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { +func resourceStorageShareStateUpgradeV0ToV1(rawState map[string]interface{}, _ interface{}) (map[string]interface{}, error) { shareName := rawState["name"].(string) resourceGroup := rawState["resource_group_name"].(string) accountName := rawState["storage_account_name"].(string) diff --git a/azurerm/resource_arm_storage_table_test.go b/azurerm/resource_arm_storage_table_test.go index 42aa58d1142b..43e6ea85a9bd 100644 --- a/azurerm/resource_arm_storage_table_test.go +++ b/azurerm/resource_arm_storage_table_test.go @@ -5,7 +5,6 @@ import ( "strings" "testing" - "github.com/Azure/azure-sdk-for-go/storage" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -15,7 +14,6 @@ import ( func TestAccAzureRMStorageTable_basic(t *testing.T) { resourceName := "azurerm_storage_table.test" - var table storage.Table ri := tf.AccRandTimeInt() rs := strings.ToLower(acctest.RandString(11)) @@ -29,7 +27,7 @@ func TestAccAzureRMStorageTable_basic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMStorageTableExists(resourceName, &table), + testCheckAzureRMStorageTableExists(resourceName), ), }, { @@ -48,7 +46,6 @@ func TestAccAzureRMStorageTable_requiresImport(t *testing.T) { } resourceName := "azurerm_storage_table.test" - var table storage.Table ri := tf.AccRandTimeInt() rs := strings.ToLower(acctest.RandString(11)) @@ -62,7 +59,7 @@ func TestAccAzureRMStorageTable_requiresImport(t *testing.T) { { Config: testAccAzureRMStorageTable_basic(ri, rs, location), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMStorageTableExists(resourceName, &table), + testCheckAzureRMStorageTableExists(resourceName), ), }, { @@ -74,8 +71,6 @@ func TestAccAzureRMStorageTable_requiresImport(t *testing.T) { } func TestAccAzureRMStorageTable_disappears(t *testing.T) { - var table storage.Table - ri := tf.AccRandTimeInt() rs := strings.ToLower(acctest.RandString(11)) config := testAccAzureRMStorageTable_basic(ri, rs, testLocation()) @@ -88,8 +83,8 @@ func TestAccAzureRMStorageTable_disappears(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMStorageTableExists("azurerm_storage_table.test", &table), - testAccARMStorageTableDisappears("azurerm_storage_table.test", &table), + testCheckAzureRMStorageTableExists("azurerm_storage_table.test"), + testAccARMStorageTableDisappears("azurerm_storage_table.test"), ), ExpectNonEmptyPlan: true, }, @@ -98,8 +93,6 @@ func TestAccAzureRMStorageTable_disappears(t *testing.T) { } func TestAccAzureRMStorageTable_acl(t *testing.T) { - var table storage.Table - ri := tf.AccRandTimeInt() rs := strings.ToLower(acctest.RandString(11)) location := testLocation() @@ -113,7 +106,7 @@ func TestAccAzureRMStorageTable_acl(t *testing.T) { { Config: testAccAzureRMStorageTable_acl(ri, rs, location), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMStorageTableExists(resourceName, &table), + testCheckAzureRMStorageTableExists(resourceName), ), }, { @@ -124,7 +117,7 @@ func TestAccAzureRMStorageTable_acl(t *testing.T) { { Config: testAccAzureRMStorageTable_aclUpdated(ri, rs, location), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMStorageTableExists(resourceName, &table), + testCheckAzureRMStorageTableExists(resourceName), ), }, { @@ -136,7 +129,7 @@ func TestAccAzureRMStorageTable_acl(t *testing.T) { }) } -func testCheckAzureRMStorageTableExists(resourceName string, t *storage.Table) resource.TestCheckFunc { +func testCheckAzureRMStorageTableExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] @@ -176,7 +169,7 @@ func testCheckAzureRMStorageTableExists(resourceName string, t *storage.Table) r } } -func testAccARMStorageTableDisappears(resourceName string, t *storage.Table) resource.TestCheckFunc { +func testAccARMStorageTableDisappears(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] if !ok { From 1ecb48bf30b12123429c03b9c8be782fcea8ca5d Mon Sep 17 00:00:00 2001 From: kt Date: Thu, 8 Aug 2019 07:37:58 -0700 Subject: [PATCH 2/2] address pr comments --- azurerm/resource_arm_storage_share.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azurerm/resource_arm_storage_share.go b/azurerm/resource_arm_storage_share.go index 82444c768320..d0f2834ac733 100644 --- a/azurerm/resource_arm_storage_share.go +++ b/azurerm/resource_arm_storage_share.go @@ -313,7 +313,8 @@ func resourceArmStorageShareDelete(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error building File Share Client for Storage Account %q (Resource Group %q): %s", id.AccountName, *resourceGroup, err) } - if _, err := client.Delete(ctx, id.AccountName, id.ShareName, true); err != nil { + deleteSnapshots := true + if _, err := client.Delete(ctx, id.AccountName, id.ShareName, deleteSnapshots); err != nil { return fmt.Errorf("Error deleting File Share %q (Storage Account %q / Resource Group %q): %s", id.ShareName, id.AccountName, *resourceGroup, err) }