Skip to content

Commit

Permalink
Add feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyTobi committed Nov 30, 2023
1 parent 6296925 commit 555cb0c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type LocationDataSource struct{}

type LocationDataSourceModel struct {
Location string `tfschema:"location"`
RegionType string `tfschema:"region_type"`
DisplayName string `tfschema:"display_name"`
ZoneMappings []LocationZoneMapping `tfschema:"zone_mappings"`
}
Expand All @@ -50,10 +49,6 @@ func (r LocationDataSource) Arguments() map[string]*pluginsdk.Schema {

func (r LocationDataSource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
"region_type": {
Type: pluginsdk.TypeString,
Computed: true,
},
"display_name": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -116,7 +111,6 @@ func (r LocationDataSource) Read() sdk.ResourceFunc {

var state LocationDataSourceModel
state.ZoneMappings = flattenZonesMapping(locationValue)
state.RegionType = string(pointer.From(locationValue.Metadata.RegionType))
state.DisplayName = pointer.From(locationValue.DisplayName)
state.Location = normalizedLocation

Expand All @@ -129,7 +123,7 @@ func (r LocationDataSource) Read() sdk.ResourceFunc {

func getLocation(location string, input *[]resourcesSubscription.Location) (*resourcesSubscription.Location, error) {
for _, item := range *input {
if pointer.From(item.Name) == location {
if pointer.From(item.Name) == location && pointer.From(item.Metadata.RegionType) == "Physical" {
return &item, nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

type LocationsDataSource struct{}

func TestAccDataSourceLocation_NonExistingRegion(t *testing.T) {
func TestAccLocationDataSource_NonExistingRegion(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_location", "test")

data.DataSourceTest(t, []acceptance.TestStep{
Expand All @@ -25,14 +25,13 @@ func TestAccDataSourceLocation_NonExistingRegion(t *testing.T) {
})
}

func TestAccDataSourceLocation_westUS(t *testing.T) {
func TestAccLocationDataSource_westUS(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_location", "test")

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: LocationsDataSource{}.basic("westus"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("region_type").HasValue("Physical"),
check.That(data.ResourceName).Key("display_name").HasValue("West US"),
check.That(data.ResourceName).Key("zone_mappings.0.logical_zone").HasValue("1"),
check.That(data.ResourceName).Key("zone_mappings.1.logical_zone").HasValue("2"),
Expand Down
4 changes: 2 additions & 2 deletions website/docs/d/location.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: |-

# Data Source: azurerm_location

Use this data source to access information of a specific location.
Use this data source to access information of a specific physical location.

## Example Usage

Expand Down Expand Up @@ -47,4 +47,4 @@ A `zone_mappings` block exports the following:

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:

* `read` - (Defaults to 5 minutes) Used when retrieving the Extended Locations.
* `read` - (Defaults to 5 minutes) Used when retrieving the Location.

0 comments on commit 555cb0c

Please sign in to comment.