Skip to content
Closed
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
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bug Fixes

* Recreate `databricks_access_control_rule_set` when the `name` changes ([#4572](https://github.com/databricks/terraform-provider-databricks/pull/4572)).
* Fix renaming of `databricks_catalog` resources ([#4579](https://github.com/databricks/terraform-provider-databricks/pull/4579)).

### Documentation

Expand Down
6 changes: 5 additions & 1 deletion catalog/resource_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func ResourceCatalog() common.Resource {
updateCatalogRequest.ForceSendFields = append(updateCatalogRequest.ForceSendFields, "Comment")
}

if d.HasChange("name") {
newName := d.Get("name").(string)
updateCatalogRequest.NewName = newName
}

updateCatalogRequest.Owner = ""
// The only option allowed in update is "authorized_paths". All other options must be removed.
if opts := updateCatalogRequest.Options; opts != nil {
Expand All @@ -162,7 +167,6 @@ func ResourceCatalog() common.Resource {
}
}
ci, err := w.Catalogs.Update(ctx, updateCatalogRequest)

if err != nil {
if d.HasChange("owner") {
// Rollback
Expand Down
14 changes: 11 additions & 3 deletions catalog/resource_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func TestCatalogCreateCannotDeleteDefaultSchema(t *testing.T) {
}.Apply(t)
require.Error(t, err)
assert.Equal(t, "cannot remove new catalog default schema: Something", fmt.Sprint(err))

}

func TestUpdateCatalog(t *testing.T) {
Expand All @@ -205,8 +204,17 @@ func TestUpdateCatalog(t *testing.T) {
Comment: "c",
Owner: "administrators",
}, nil)
e.GetByName(mock.Anything, "a").Return(&catalog.CatalogInfo{
e.Update(mock.Anything, catalog.UpdateCatalog{
Name: "a",
NewName: "b",
Comment: "c",
}).Return(&catalog.CatalogInfo{
Name: "b",
Comment: "c",
Owner: "administrators",
}, nil)
e.GetByName(mock.Anything, "b").Return(&catalog.CatalogInfo{
Name: "b",
Comment: "c",
Owner: "administrators",
}, nil)
Expand All @@ -220,7 +228,7 @@ func TestUpdateCatalog(t *testing.T) {
"comment": "c",
},
HCL: `
name = "a"
name = "b"
comment = "c"
owner = "administrators"
`,
Expand Down