Skip to content

Commit

Permalink
[Fix] Fixed read method of databricks_entitlements resource (#3858)
Browse files Browse the repository at this point in the history
## Changes
- Populate missing ids when importing `databricks_entitlements`
resource. Resolve #3856

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [x] `make test` run locally

---------

Co-authored-by: Alex Ott <alexott@gmail.com>
  • Loading branch information
nkvuong and alexott authored Aug 7, 2024
1 parent 560e753 commit 0f6278d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scim/resource_entitlement.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,23 @@ func ResourceEntitlements() common.Resource {
if err != nil {
return err
}
d.Set("group_id", split[1])
group.Entitlements.generateEmpty(d)
return group.Entitlements.readIntoData(d)
case "user":
user, err := NewUsersAPI(ctx, c).Read(split[1], "entitlements")
if err != nil {
return err
}
d.Set("user_id", split[1])
user.Entitlements.generateEmpty(d)
return user.Entitlements.readIntoData(d)
case "spn":
spn, err := NewServicePrincipalsAPI(ctx, c).Read(split[1], "entitlements")
if err != nil {
return err
}
d.Set("service_principal_id", split[1])
spn.Entitlements.generateEmpty(d)
return spn.Entitlements.readIntoData(d)
}
Expand Down
19 changes: 19 additions & 0 deletions scim/resource_entitlement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ func TestResourceEntitlementsGroupRead(t *testing.T) {
})
}

func TestResourceEntitlementsGroupImport(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=entitlements",
Response: oldGroup,
},
},
Resource: ResourceEntitlements(),
New: true,
Read: true,
ID: "group/abc",
}.ApplyAndExpectData(t, map[string]any{
"group_id": "abc",
"allow_cluster_create": true,
})
}

func TestResourceEntitlementsGroupReadEmpty(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
Expand Down

0 comments on commit 0f6278d

Please sign in to comment.