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

azurerm_storage_table_entities Data Source - Fix items.x.properties hold only one kv bug #25211

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
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo

result := TableEntitiyDataSourceModel{}

properties := map[string]interface{}{}
for k, v := range entity {
properties := map[string]interface{}{}
if k == "PartitionKey" {
result.PartitionKey = v.(string)
continue
Expand Down Expand Up @@ -200,7 +200,6 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo
}

properties[k+"@odata.type"] = dtype
result.Properties = properties
} else {
// special handling for property types that do not require the annotation to be present
// https://docs.microsoft.com/en-us/rest/api/storageservices/payload-format-for-table-service-operations#property-types-in-a-json-feed
Expand All @@ -223,9 +222,9 @@ func flattenEntityWithMetadata(entity map[string]interface{}) TableEntitiyDataSo
default:
log.Printf("[WARN] key %q with unexpected type %T", k, c)
}
result.Properties = properties
}
}
result.Properties = properties

return result
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAccDataSourceStorageTableEntities_basic(t *testing.T) {
Config: StorageTableEntitiesDataSource{}.basicWithDataSource(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("items.#").HasValue("2"),
check.That(data.ResourceName).Key("items.0.properties.%").HasValue("2"),
),
},
})
Expand Down Expand Up @@ -74,7 +75,8 @@ resource "azurerm_storage_table_entity" "test" {
row_key = "testrow"

entity = {
testkey = "testval"
testkey1 = "testval11"
testkey2 = "testval12"
}
}

Expand All @@ -86,7 +88,8 @@ resource "azurerm_storage_table_entity" "test2" {
row_key = "testrow2"

entity = {
testkey = "testval2"
testkey1 = "testval21"
testkey2 = "testval22"
}
}

Expand All @@ -98,7 +101,8 @@ resource "azurerm_storage_table_entity" "testselector" {
row_key = "testrow"

entity = {
testkey = "testval"
testkey1 = "testval31"
testkey2 = "testval32"
testselector = "testselectorval"
}
}
Expand Down
Loading