Skip to content

Commit

Permalink
[Fix] reading databricks_metastore_assignment when importing resource
Browse files Browse the repository at this point in the history
The `Read` method on workspace level wasn't filling all attributes and this led to the
configuration drift after import.
  • Loading branch information
alexott committed Jul 26, 2024
1 parent 06c761a commit 7872266
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions catalog/resource_metastore_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func ResourceMetastoreAssignment() common.Resource {
return err
}
d.Set("metastore_id", ma.MetastoreId)
d.Set("default_catalog_name", ma.DefaultCatalogName)
d.Set("workspace_id", workspaceId)
return nil
})
},
Expand Down
23 changes: 23 additions & 0 deletions catalog/resource_metastore_assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ func TestMetastoreAssignment_Create(t *testing.T) {
}.ApplyNoError(t)
}

func TestMetastoreAssignment_Import(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.1/unity-catalog/current-metastore-assignment",
Response: catalog.MetastoreAssignment{
MetastoreId: "a",
WorkspaceId: 123,
DefaultCatalogName: "test_metastore",
},
},
},
Resource: ResourceMetastoreAssignment(),
Read: true,
ID: "123|a",
}.ApplyAndExpectData(t, map[string]any{
"workspace_id": 123,
"metastore_id": "a",
"default_catalog_name": "test_metastore",
})
}

func TestMetastoreAssignmentAccount_Create(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/metastore_assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The following arguments are required:

In addition to all arguments above, the following attributes are exported:

* `id` - ID of this metastore assignment in form of `<metastore_id>|<metastore_id>`.
* `id` - ID of this metastore assignment in form of `<workspace_id>|<metastore_id>`.

## Import

Expand Down

0 comments on commit 7872266

Please sign in to comment.