From a5ce6cfd4cc8218ea1a6642f6357bfd26268aca3 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 18 Mar 2019 07:51:15 +0100 Subject: [PATCH 1/2] Fixing errors caught by the updated linter --- azurerm/data_source_notification_hub.go | 4 ++-- azurerm/encryption_settings.go | 2 +- azurerm/resource_arm_application_gateway.go | 4 ++-- azurerm/resource_arm_key_vault_certificate.go | 2 +- azurerm/resource_arm_monitor_log_profile.go | 12 +++++------- azurerm/resource_arm_notification_hub.go | 8 ++++---- azurerm/resource_arm_role_assignment.go | 2 +- azurerm/resource_arm_sql_database.go | 4 ---- azurerm/resource_arm_virtual_machine.go | 2 +- 9 files changed, 17 insertions(+), 23 deletions(-) diff --git a/azurerm/data_source_notification_hub.go b/azurerm/data_source_notification_hub.go index 06d3a705438e..c951f4474688 100644 --- a/azurerm/data_source_notification_hub.go +++ b/azurerm/data_source_notification_hub.go @@ -112,12 +112,12 @@ func dataSourceNotificationHubRead(d *schema.ResourceData, meta interface{}) err if props := credentials.PnsCredentialsProperties; props != nil { apns := flattenNotificationHubsDataSourceAPNSCredentials(props.ApnsCredential) - if d.Set("apns_credential", apns); err != nil { + if setErr := d.Set("apns_credential", apns); setErr != nil { return fmt.Errorf("Error setting `apns_credential`: %+v", err) } gcm := flattenNotificationHubsDataSourceGCMCredentials(props.GcmCredential) - if d.Set("gcm_credential", gcm); err != nil { + if setErr := d.Set("gcm_credential", gcm); setErr != nil { return fmt.Errorf("Error setting `gcm_credential`: %+v", err) } } diff --git a/azurerm/encryption_settings.go b/azurerm/encryption_settings.go index d51791b300d0..1dae90ab4092 100644 --- a/azurerm/encryption_settings.go +++ b/azurerm/encryption_settings.go @@ -119,7 +119,7 @@ func flattenManagedDiskEncryptionSettings(encryptionSettings *compute.Encryption keys["key_url"] = *key.KeyURL - if vault := key.SourceVault; key != nil { + if vault := key.SourceVault; vault != nil { keys["source_vault_id"] = *vault.ID } diff --git a/azurerm/resource_arm_application_gateway.go b/azurerm/resource_arm_application_gateway.go index 59386779e3d7..49a343f045ed 100644 --- a/azurerm/resource_arm_application_gateway.go +++ b/azurerm/resource_arm_application_gateway.go @@ -1060,7 +1060,7 @@ func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error setting `url_path_map`: %+v", setErr) } - if setErr := d.Set("waf_configuration", flattenApplicationGatewayWafConfig(props.WebApplicationFirewallConfiguration)); err != nil { + if setErr := d.Set("waf_configuration", flattenApplicationGatewayWafConfig(props.WebApplicationFirewallConfiguration)); setErr != nil { return fmt.Errorf("Error setting `waf_configuration`: %+v", setErr) } } @@ -2227,7 +2227,7 @@ func flattenApplicationGatewayURLPathMaps(input *[]network.ApplicationGatewayURL ruleOutput["name"] = *rule.Name } - if ruleProps := rule.ApplicationGatewayPathRulePropertiesFormat; props != nil { + if ruleProps := rule.ApplicationGatewayPathRulePropertiesFormat; ruleProps != nil { if pool := ruleProps.BackendAddressPool; pool != nil && pool.ID != nil { poolId, err := parseAzureResourceID(*pool.ID) if err != nil { diff --git a/azurerm/resource_arm_key_vault_certificate.go b/azurerm/resource_arm_key_vault_certificate.go index 10f73b1f9ac2..6f5877a5b1ae 100644 --- a/azurerm/resource_arm_key_vault_certificate.go +++ b/azurerm/resource_arm_key_vault_certificate.go @@ -34,7 +34,7 @@ func resourceArmKeyVaultChildResourceImporter(d *schema.ResourceData, meta inter return []*schema.ResourceData{d}, fmt.Errorf("Error retrieving the Resource ID the Key Vault at URL %q: %s", id.KeyVaultBaseUrl, err) } if id == nil { - return []*schema.ResourceData{d}, fmt.Errorf("Unable to locate the Resource ID for the Key Vault at URL %q: %s", id.KeyVaultBaseUrl, err) + return []*schema.ResourceData{d}, fmt.Errorf("Unable to locate the Resource ID for the Key Vault at URL %q", id.KeyVaultBaseUrl) } d.Set("key_vault_id", kvid) diff --git a/azurerm/resource_arm_monitor_log_profile.go b/azurerm/resource_arm_monitor_log_profile.go index 1a370fa0f61e..d0f127bf5ce7 100644 --- a/azurerm/resource_arm_monitor_log_profile.go +++ b/azurerm/resource_arm_monitor_log_profile.go @@ -254,14 +254,12 @@ func flattenAzureRmLogProfileRetentionPolicy(input *insights.RetentionPolicy) [] } result := make(map[string]interface{}) - if input != nil { - if input.Enabled != nil { - result["enabled"] = *input.Enabled - } + if input.Enabled != nil { + result["enabled"] = *input.Enabled + } - if input.Days != nil { - result["days"] = *input.Days - } + if input.Days != nil { + result["days"] = *input.Days } return []interface{}{result} diff --git a/azurerm/resource_arm_notification_hub.go b/azurerm/resource_arm_notification_hub.go index 3e24861e78e6..37aedc794f37 100644 --- a/azurerm/resource_arm_notification_hub.go +++ b/azurerm/resource_arm_notification_hub.go @@ -254,13 +254,13 @@ func resourceArmNotificationHubRead(d *schema.ResourceData, meta interface{}) er if props := credentials.PnsCredentialsProperties; props != nil { apns := flattenNotificationHubsAPNSCredentials(props.ApnsCredential) - if d.Set("apns_credential", apns); err != nil { - return fmt.Errorf("Error setting `apns_credential`: %+v", err) + if setErr := d.Set("apns_credential", apns); setErr != nil { + return fmt.Errorf("Error setting `apns_credential`: %+v", setErr) } gcm := flattenNotificationHubsGCMCredentials(props.GcmCredential) - if d.Set("gcm_credential", gcm); err != nil { - return fmt.Errorf("Error setting `gcm_credential`: %+v", err) + if setErr := d.Set("gcm_credential", gcm); setErr != nil { + return fmt.Errorf("Error setting `gcm_credential`: %+v", setErr) } } diff --git a/azurerm/resource_arm_role_assignment.go b/azurerm/resource_arm_role_assignment.go index 57b1cc1eb553..038202c8fdf4 100644 --- a/azurerm/resource_arm_role_assignment.go +++ b/azurerm/resource_arm_role_assignment.go @@ -170,7 +170,7 @@ func resourceArmRoleAssignmentRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error loading Role Definition %q: %+v", *roleId, err) } - if roleProps := roleResp.RoleDefinitionProperties; props != nil { + if roleProps := roleResp.RoleDefinitionProperties; roleProps != nil { d.Set("role_definition_name", roleProps.RoleName) } } diff --git a/azurerm/resource_arm_sql_database.go b/azurerm/resource_arm_sql_database.go index 55dd2c73df02..2786d9adae54 100644 --- a/azurerm/resource_arm_sql_database.go +++ b/azurerm/resource_arm_sql_database.go @@ -559,10 +559,6 @@ func resourceArmSqlDatabaseDelete(d *schema.ResourceData, meta interface{}) erro return nil } - return fmt.Errorf("Error making Read request on Sql Database %s: %+v", name, err) - } - - if err != nil { return fmt.Errorf("Error deleting SQL Database: %+v", err) } diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index e37ed69d915a..33f12e538c3c 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -1911,7 +1911,7 @@ func determineVirtualMachineIPAddress(ctx context.Context, meta interface{}, pro return "", fmt.Errorf("Error obtaining Public IP %q (Resource Group %q): %+v", name, resourceGroup, err) } - if pipProps := pip.PublicIPAddressPropertiesFormat; props != nil { + if pipProps := pip.PublicIPAddressPropertiesFormat; pipProps != nil { if ip := pipProps.IPAddress; ip != nil { return *ip, nil } From 0dbef02d406ccb2d2fedf8dafa0d46571777482e Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 18 Mar 2019 08:01:23 +0100 Subject: [PATCH 2/2] Removing an if statement which couldn't be hit --- azurerm/resource_arm_key_vault_certificate.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/azurerm/resource_arm_key_vault_certificate.go b/azurerm/resource_arm_key_vault_certificate.go index 6f5877a5b1ae..d4e74ca374eb 100644 --- a/azurerm/resource_arm_key_vault_certificate.go +++ b/azurerm/resource_arm_key_vault_certificate.go @@ -33,9 +33,6 @@ func resourceArmKeyVaultChildResourceImporter(d *schema.ResourceData, meta inter if err != nil { return []*schema.ResourceData{d}, fmt.Errorf("Error retrieving the Resource ID the Key Vault at URL %q: %s", id.KeyVaultBaseUrl, err) } - if id == nil { - return []*schema.ResourceData{d}, fmt.Errorf("Unable to locate the Resource ID for the Key Vault at URL %q", id.KeyVaultBaseUrl) - } d.Set("key_vault_id", kvid)