Skip to content

Commit

Permalink
Updating PR to resolve recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
midacts committed Sep 20, 2019
1 parent e4bd685 commit 5f86064
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions azurerm/data_source_public_ip_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func dataSourceArmPublicIpPrefix() *schema.Resource {
Computed: true,
},

"zones": azure.SchemaSingleZone(),
"zones": azure.SchemaZonesComputed(),

"tags": tags.Schema(),
"tags": tags.SchemaDataSource(),
},
}
}
Expand All @@ -50,16 +50,26 @@ func dataSourceArmPublicIpPrefixRead(d *schema.ResourceData, meta interface{}) e
ctx := meta.(*ArmClient).StopContext

name := d.Get("name").(string)
resGroup := d.Get("resource_group_name").(string)
resp, err := client.Get(ctx, resGroup, name, "")
resourceGroup := d.Get("resource_group_name").(string)
resp, err := client.Get(ctx, resourceGroup, name, "")
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error: Public IP prefix %q was not found", name)
return fmt.Errorf("Error: Public IP prefix %q was not found in Resource Group %q", name, resourceGroup)
}
return err
return fmt.Errorf("Error retrieving Public IP Prefix %q (Resource Group %q): %+v", name, resourceGroup, err)
}

d.SetId(*resp.ID)

return resourceArmPublicIpPrefixRead(d, meta)
d.Set("zones", resp.Zones)
if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
if sku := resp.Sku; sku != nil {
d.Set("sku", string(sku.Name))
}
if props := resp.PublicIPPrefixPropertiesFormat; props != nil {
d.Set("prefix_length", props.PrefixLength)
d.Set("ip_prefix", props.IPPrefix)
}
return tags.FlattenAndSet(d, resp.Tags)
}

0 comments on commit 5f86064

Please sign in to comment.