Skip to content

Commit

Permalink
Feat: new custom role resource (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber authored Nov 30, 2022
1 parent 23f36e5 commit 631df81
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ func (client *HttpClient) Post(path string, request interface{}, response interf
}

func (client *HttpClient) Put(path string, request interface{}, response interface{}) error {
result, err := client.request().
SetBody(request).
SetResult(response).
Put(path)
req := client.request().SetBody(request)
if response != nil {
req = req.SetResult(response)
}

result, err := req.Put(path)

return client.httpResult(result, err)
}

Expand Down
15 changes: 15 additions & 0 deletions examples/resources/env0_user_organization_assignment/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "env0_user" "user_example" {
email = "[email protected]"
}

resource "env0_custom_role" "custom_role" {
name = "custom-role"
permissions = [
"EDIT_PROJECT_SETTINGS"
]
}

resource "env0_user_organization_assignment" "user_org" {
user_id = data.env0_user.user_example.id
custom_role_id = env0_custom_role.custom_role.id
}
10 changes: 10 additions & 0 deletions tests/integration/026_custom_role/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ data "env0_custom_role" "roles" {
for_each = toset(data.env0_custom_roles.all_roles.names)
name = each.value
}

resource "env0_api_key" "test_api_key" {
name = "api-key-${random_string.random.result}"
}

resource "env0_user_organization_assignment" "user_org" {
user_id = env0_api_key.test_api_key.id
custom_role_id = var.second_run ? null : env0_custom_role.custom_role1.id
role = var.second_run ? "Admin" : null
}

0 comments on commit 631df81

Please sign in to comment.