Skip to content

Commit

Permalink
provider: misc golang inspection cleanup (#4039)
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Aug 8, 2019
1 parent 3cf5d0d commit 1ecb935
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 152 deletions.
2 changes: 1 addition & 1 deletion azurerm/data_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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), ";")

Expand Down
42 changes: 0 additions & 42 deletions azurerm/helpers/azure/automation_variable.go

This file was deleted.

4 changes: 2 additions & 2 deletions azurerm/helpers/azure/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/hdinsight.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ".")
Expand Down
2 changes: 1 addition & 1 deletion azurerm/helpers/azure/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
57 changes: 0 additions & 57 deletions azurerm/helpers/azure/sender.go

This file was deleted.

4 changes: 2 additions & 2 deletions azurerm/helpers/validate/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/storage/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_batch_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_container_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,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)
}

Expand Down Expand Up @@ -1021,7 +1021,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)
}
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_iot_dps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}

Expand Down
10 changes: 5 additions & 5 deletions azurerm/resource_arm_logic_app_action_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},

Expand Down
10 changes: 5 additions & 5 deletions azurerm/resource_arm_logic_app_trigger_http_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},

Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_metric_alertrule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,20 @@ 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) },
Providers: testAccProviders,
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"),
},
},
Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_monitor_metric_alertrule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,20 @@ 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) },
Providers: testAccProviders,
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"),
},
},
Expand Down
5 changes: 2 additions & 3 deletions azurerm/resource_arm_policy_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -101,7 +100,7 @@ func TestAccAzureRMPolicyDefinitionAtMgmtGroup_basic(t *testing.T) {
{
Config: testAzureRMPolicyDefinition_ManagementGroup(ri),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(resourceName, mgmtGroupName),
testCheckAzureRMPolicyDefinitionExistsInMgmtGroup(resourceName),
),
},
{
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_sql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_storage_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_storage_share_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 1ecb935

Please sign in to comment.