Skip to content

Commit

Permalink
Export tags for azurerm_search_service data provider (#26978)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavmb authored Aug 9, 2024
1 parent d54b72a commit a6156b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/services/search/search_service_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/adminkeys"
"github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/querykeys"
"github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/services"
Expand Down Expand Up @@ -84,6 +85,8 @@ func dataSourceSearchService() *pluginsdk.Resource {
},

"identity": commonschema.SystemAssignedIdentityComputed(),

"tags": commonschema.TagsDataSource(),
},
}
}
Expand Down Expand Up @@ -133,6 +136,10 @@ func dataSourceSearchServiceRead(d *pluginsdk.ResourceData, meta interface{}) er
if err = d.Set("identity", identity.FlattenSystemAssigned(model.Identity)); err != nil {
return fmt.Errorf("setting `identity`: %s", err)
}

if err := tags.FlattenAndSet(d, model.Tags); err != nil {
return fmt.Errorf("setting `tags`: %+v", err)
}
}

primaryKey := ""
Expand Down
5 changes: 5 additions & 0 deletions internal/services/search/search_service_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestAccDataSourceSearchService_basic(t *testing.T) {
check.That(data.ResourceName).Key("identity.0.type").Exists(),
check.That(data.ResourceName).Key("identity.0.principal_id").Exists(),
check.That(data.ResourceName).Key("identity.0.tenant_id").Exists(),
check.That(data.ResourceName).Key("tags.environment").HasValue("production"),
),
},
})
Expand All @@ -54,6 +55,10 @@ resource "azurerm_search_service" "test" {
identity {
type = "SystemAssigned"
}
tags = {
environment = "production"
}
}
data "azurerm_search_service" "test" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/search_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `replica_count` - The number of replica's which have been created.

* `tags` - A mapping of tags assigned to the resource.

* `identity` - An `identity` block as defined below.

---
Expand Down

0 comments on commit a6156b2

Please sign in to comment.