Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap d.Set("location") with a nil check call and normalize d.Get("location") #1074

Merged
merged 2 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion azurerm/data_source_application_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ func dataSourceArmApplicationSecurityGroupRead(d *schema.ResourceData, meta inte
d.SetId(*resp.ID)

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

flattenAndSetTags(d, resp.Tags)

return nil
Expand Down
4 changes: 3 additions & 1 deletion azurerm/data_source_cdn_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func dataSourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if sku := resp.Sku; sku != nil {
d.Set("sku", string(sku.Name))
Expand Down
5 changes: 4 additions & 1 deletion azurerm/data_source_eventhub_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ func dataSourceEventHubNamespaceRead(d *schema.ResourceData, meta interface{}) e
d.SetId(*resp.ID)

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("sku", string(resp.Sku.Name))
d.Set("capacity", resp.Sku.Capacity)

Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func dataSourceArmImageRead(d *schema.ResourceData, meta interface{}) error {
d.SetId(*img.ID)
d.Set("name", img.Name)
d.Set("resource_group_name", resGroup)

if location := img.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
Expand Down
5 changes: 4 additions & 1 deletion azurerm/data_source_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ func dataSourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{})

d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("applied_dns_servers", appliedDNSServers)
d.Set("dns_servers", dnsServers)
d.Set("enable_ip_forwarding", resp.EnableIPForwarding)
Expand Down
4 changes: 3 additions & 1 deletion azurerm/data_source_network_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ func dataSourceArmNetworkSecurityGroupRead(d *schema.ResourceData, meta interfac

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.SecurityGroupPropertiesFormat; props != nil {
flattenedRules := flattenNetworkSecurityRules(props.SecurityRules)
Expand Down
4 changes: 3 additions & 1 deletion azurerm/data_source_platform_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ func dataSourceArmPlatformImageRead(d *schema.ResourceData, meta interface{}) er
latestVersion := (*result.Value)[len(*result.Value)-1]

d.SetId(*latestVersion.ID)
if location := latestVersion.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("location", azureRMNormalizeLocation(*latestVersion.Location))
d.Set("publisher", publisher)
d.Set("offer", offer)
d.Set("sku", sku)
Expand Down
5 changes: 4 additions & 1 deletion azurerm/data_source_scheduler_job_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ func dataSourceArmSchedulerJobCollectionRead(d *schema.ResourceData, meta interf

//standard properties
d.Set("name", collection.Name)
d.Set("location", azureRMNormalizeLocation(*collection.Location))
d.Set("resource_group_name", resourceGroup)
if location := collection.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

flattenAndSetTags(d, collection.Tags)

//resource specific
Expand Down
1 change: 0 additions & 1 deletion azurerm/data_source_virtual_network_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func dataSourceArmVirtualNetworkGatewayRead(d *schema.ResourceData, meta interfa

d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)

if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error
}

resGroup := d.Get("resource_group_name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
appServicePlanId := d.Get("app_service_plan_id").(string)
enabled := d.Get("enabled").(bool)
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -492,7 +492,9 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {

d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.SiteProperties; props != nil {
d.Set("app_service_plan_id", props.ServerFarmID)
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac

resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
kind := d.Get("kind").(string)
tags := d.Get("tags").(map[string]interface{})

Expand Down Expand Up @@ -177,7 +177,9 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err

d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
d.Set("kind", resp.Kind)

if props := resp.AppServicePlanProperties; props != nil {
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_app_service_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func resourceArmAppServiceSlotCreate(d *schema.ResourceData, meta interface{}) e

slot := d.Get("name").(string)
resGroup := d.Get("resource_group_name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
appServiceName := d.Get("app_service_name").(string)
appServicePlanId := d.Get("app_service_plan_id").(string)
enabled := d.Get("enabled").(bool)
Expand Down Expand Up @@ -418,7 +418,9 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err
d.Set("name", slot)
d.Set("app_service_name", appServiceName)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.SiteProperties; props != nil {
d.Set("app_service_plan_id", props.ServerFarmID)
Expand Down
7 changes: 5 additions & 2 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
log.Printf("[INFO] preparing arguments for AzureRM ApplicationGateway creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
tags := d.Get("tags").(map[string]interface{})

Expand Down Expand Up @@ -762,7 +762,10 @@ func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{})

d.Set("name", applicationGateway.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("location", applicationGateway.Location)
if location := applicationGateway.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("sku", schema.NewSet(hashApplicationGatewaySku, flattenApplicationGatewaySku(applicationGateway.ApplicationGatewayPropertiesFormat.Sku)))
d.Set("disabled_ssl_protocols", flattenApplicationGatewaySslPolicy(applicationGateway.ApplicationGatewayPropertiesFormat.SslPolicy))
d.Set("gateway_ip_configuration", flattenApplicationGatewayIPConfigurations(applicationGateway.ApplicationGatewayPropertiesFormat.GatewayIPConfigurations))
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func resourceArmApplicationInsightsCreateOrUpdate(d *schema.ResourceData, meta i
name := d.Get("name").(string)
resGroup := d.Get("resource_group_name").(string)
applicationType := d.Get("application_type").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
tags := d.Get("tags").(map[string]interface{})

applicationInsightsComponentProperties := insights.ApplicationInsightsComponentProperties{
Expand Down Expand Up @@ -126,7 +126,9 @@ func resourceArmApplicationInsightsRead(d *schema.ResourceData, meta interface{}

d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.ApplicationInsightsComponentProperties; props != nil {
d.Set("application_type", string(props.ApplicationType))
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_application_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func resourceArmApplicationSecurityGroupCreateUpdate(d *schema.ResourceData, met

resourceGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
tags := d.Get("tags").(map[string]interface{})

securityGroup := network.ApplicationSecurityGroup{
Expand Down Expand Up @@ -94,8 +94,10 @@ func resourceArmApplicationSecurityGroupRead(d *schema.ResourceData, meta interf
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
flattenAndSetTags(d, resp.Tags)

return nil
Expand Down
7 changes: 5 additions & 2 deletions azurerm/resource_arm_automation_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func resourceArmAutomationAccountCreateUpdate(d *schema.ResourceData, meta inter
log.Printf("[INFO] preparing arguments for AzureRM Automation Account creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
tags := d.Get("tags").(map[string]interface{})

Expand Down Expand Up @@ -116,8 +116,11 @@ func resourceArmAutomationAccountRead(d *schema.ResourceData, meta interface{})
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

flattenAndSetSku(d, resp.Sku)

flattenAndSetTags(d, resp.Tags)
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_automation_runbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func resourceArmAutomationRunbookCreateUpdate(d *schema.ResourceData, meta inter
log.Printf("[INFO] preparing arguments for AzureRM Automation Runbook creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
client.ResourceGroupName = resGroup
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -182,8 +182,10 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{})
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("account_name", accName)
if props := resp.RunbookProperties; props != nil {
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func resourceArmAvailabilitySetCreate(d *schema.ResourceData, meta interface{})
log.Printf("[INFO] preparing arguments for AzureRM Availability Set creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
updateDomainCount := d.Get("platform_update_domain_count").(int)
faultDomainCount := d.Get("platform_fault_domain_count").(int)
Expand Down Expand Up @@ -124,7 +124,9 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er
availSet := *resp.AvailabilitySetProperties
d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
d.Set("platform_update_domain_count", availSet.PlatformUpdateDomainCount)
d.Set("platform_fault_domain_count", availSet.PlatformFaultDomainCount)

Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_cdn_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro
log.Printf("[INFO] preparing arguments for Azure ARM CDN EndPoint creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resourceGroup := d.Get("resource_group_name").(string)
profileName := d.Get("profile_name").(string)
httpAllowed := d.Get("is_http_allowed").(bool)
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_cdn_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error
log.Printf("[INFO] preparing arguments for Azure ARM CDN Profile creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
sku := d.Get("sku").(string)
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -143,7 +143,9 @@ func resourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error {

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if sku := resp.Sku; sku != nil {
d.Set("sku", string(sku.Name))
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_container_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func resourceArmContainerGroupCreate(d *schema.ResourceData, meta interface{}) e
// container group properties
resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
OSType := d.Get("os_type").(string)
IPAddressType := d.Get("ip_address_type").(string)
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -276,7 +276,9 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err

d.Set("name", name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
flattenAndSetTags(d, resp.Tags)

d.Set("os_type", string(resp.OsType))
Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_container_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{}

resourceGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
sku := d.Get("sku").(string)
adminUserEnabled := d.Get("admin_enabled").(bool)
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -243,7 +243,9 @@ func resourceArmContainerRegistryRead(d *schema.ResourceData, meta interface{})

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
d.Set("admin_enabled", resp.AdminUserEnabled)
d.Set("login_server", resp.LoginServer)

Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_container_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func resourceArmContainerServiceCreate(d *schema.ResourceData, meta interface{})

resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))

orchestrationPlatform := d.Get("orchestration_platform").(string)

Expand Down Expand Up @@ -273,8 +273,10 @@ func resourceArmContainerServiceRead(d *schema.ResourceData, meta interface{}) e
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("orchestration_platform", string(resp.Properties.OrchestratorProfile.OrchestratorType))

Expand Down
6 changes: 4 additions & 2 deletions azurerm/resource_arm_cosmos_db_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func resourceArmCosmosDBAccountCreateUpdate(d *schema.ResourceData, meta interfa
log.Printf("[INFO] preparing arguments for AzureRM Cosmos DB Account creation.")

name := d.Get("name").(string)
location := d.Get("location").(string)
location := azureRMNormalizeLocation(d.Get("location").(string))
resGroup := d.Get("resource_group_name").(string)
kind := d.Get("kind").(string)
offerType := d.Get("offer_type").(string)
Expand Down Expand Up @@ -228,8 +228,10 @@ func resourceArmCosmosDBAccountRead(d *schema.ResourceData, meta interface{}) er
}

d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
d.Set("kind", string(resp.Kind))
d.Set("offer_type", string(resp.DatabaseAccountOfferType))
d.Set("ip_range_filter", resp.IPRangeFilter)
Expand Down
Loading