-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add org support for role None (#1068)
* Add org support for role None * Regenerating docs * Update docs/resources/organization.md Co-authored-by: Eric Leijonmarck <[email protected]> * Update internal/resources/grafana/resource_organization.go Co-authored-by: Eric Leijonmarck <[email protected]> * Regenerating docs * Testing assignment and removal of role none * making ad-hoc test * Rename list from nones to users_without_access * Regen docs and map roles to role lists * More generic functions to obtain role name and role list name * Update docs/resources/organization.md Co-authored-by: Ieva <[email protected]> * Update internal/resources/grafana/resource_organization.go Co-authored-by: Ieva <[email protected]> * Fix semver check + add 10.2 notice --------- Co-authored-by: Eric Leijonmarck <[email protected]> Co-authored-by: Ieva <[email protected]> Co-authored-by: Julien Duchesne <[email protected]>
- Loading branch information
1 parent
607305c
commit 5f99abc
Showing
3 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ func TestAccOrganization_users(t *testing.T) { | |
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "viewers.#", | ||
), | ||
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "users_without_access.#", | ||
), | ||
), | ||
}, | ||
{ | ||
|
@@ -110,6 +113,9 @@ func TestAccOrganization_users(t *testing.T) { | |
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "viewers.#", | ||
), | ||
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "users_without_access.#", | ||
), | ||
), | ||
}, | ||
{ | ||
|
@@ -128,6 +134,64 @@ func TestAccOrganization_users(t *testing.T) { | |
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "viewers.#", "0", | ||
), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "users_without_access.#", "0", | ||
), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccOrganization_roleNoneUser(t *testing.T) { | ||
testutils.CheckOSSTestsEnabled(t, ">=10.2.0") | ||
|
||
var org gapi.Org | ||
|
||
resource.Test(t, resource.TestCase{ | ||
ProviderFactories: testutils.ProviderFactories, | ||
CheckDestroy: testAccOrganizationCheckDestroy(&org), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccOrganizationConfig_usersCreate, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccOrganizationCheckExists("grafana_organization.test", &org), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "admins.#", "1", | ||
), | ||
), | ||
}, | ||
{ | ||
Config: testAccOrganization_roleNoneUsersUpdate, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccOrganizationCheckExists("grafana_organization.test", &org), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "name", "terraform-acc-test", | ||
), | ||
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "admins.#", | ||
), | ||
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "editors.#", | ||
), | ||
resource.TestCheckNoResourceAttr( | ||
"grafana_organization.test", "viewers.#", | ||
), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "users_without_access.#", "1", | ||
), | ||
), | ||
}, | ||
{ | ||
Config: testAccOrganizationConfig_usersRemove, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccOrganizationCheckExists("grafana_organization.test", &org), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "admins.#", "0", | ||
), | ||
resource.TestCheckResourceAttr( | ||
"grafana_organization.test", "users_without_access.#", "0", | ||
), | ||
), | ||
}, | ||
}, | ||
|
@@ -329,6 +393,18 @@ resource "grafana_organization" "test" { | |
] | ||
} | ||
` | ||
const testAccOrganization_roleNoneUsersUpdate = ` | ||
resource "grafana_organization" "test" { | ||
name = "terraform-acc-test" | ||
admin_user = "admin" | ||
create_users = false | ||
editors = [] | ||
users_without_access = [ | ||
"[email protected]", | ||
] | ||
} | ||
` | ||
|
||
const testAccOrganizationConfig_usersRemove = ` | ||
resource "grafana_organization" "test" { | ||
name = "terraform-acc-test" | ||
|