diff --git a/README.md b/README.md index 9d476b8..8a0a281 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ data "bitbucketserver_application_properties" "main" {} ### Application Properties ```hcl -data "bitbucketserver_project_groups" "proj" { +data "bitbucketserver_project_permissions_groups" "proj" { project = "TEST" } ``` diff --git a/bitbucket/data_project_groups.go b/bitbucket/data_project_permission_groups.go similarity index 67% rename from bitbucket/data_project_groups.go rename to bitbucket/data_project_permission_groups.go index b67bbd5..099744f 100644 --- a/bitbucket/data_project_groups.go +++ b/bitbucket/data_project_permission_groups.go @@ -6,25 +6,25 @@ import ( "github.com/hashicorp/terraform/helper/schema" ) -type ProjectGroup struct { +type ProjectPermissionsGroup struct { Group struct { Name string `json:"name,omitempty"` } `json:"group,omitempty"` Permission string `json:"permission,omitempty"` } -type PaginatedProjectGroups struct { - Values []ProjectGroup `json:"values,omitempty"` - Size int `json:"size,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Start int `json:"start,omitempty"` - NextPageStart int `json:"nextPageStart,omitempty"` +type PaginatedProjectPermissionsGroups struct { + Values []ProjectPermissionsGroup `json:"values,omitempty"` + Size int `json:"size,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Start int `json:"start,omitempty"` + NextPageStart int `json:"nextPageStart,omitempty"` } -func dataSourceProjectGroups() *schema.Resource { +func dataSourceProjectPermissionsGroups() *schema.Resource { return &schema.Resource{ - Read: dataSourceProjectGroupsRead, + Read: dataSourceProjectPermissionsGroupsRead, Schema: map[string]*schema.Schema{ "project": { @@ -51,14 +51,14 @@ func dataSourceProjectGroups() *schema.Resource { } } -func dataSourceProjectGroupsRead(d *schema.ResourceData, m interface{}) error { +func dataSourceProjectPermissionsGroupsRead(d *schema.ResourceData, m interface{}) error { client := m.(*BitbucketClient) resourceURL := fmt.Sprintf("/rest/api/1.0/projects/%s/permissions/groups", d.Get("project").(string), ) - var projectGroups PaginatedProjectGroups + var projectGroups PaginatedProjectPermissionsGroups var terraformGroups []interface{} for { @@ -85,7 +85,7 @@ func dataSourceProjectGroupsRead(d *schema.ResourceData, m interface{}) error { d.Get("project").(string), projectGroups.NextPageStart, ) - projectGroups = PaginatedProjectGroups{} + projectGroups = PaginatedProjectPermissionsGroups{} } else { break } diff --git a/bitbucket/data_project_groups_test.go b/bitbucket/data_project_permission_groups_test.go similarity index 78% rename from bitbucket/data_project_groups_test.go rename to bitbucket/data_project_permission_groups_test.go index cf49a6b..137fce8 100644 --- a/bitbucket/data_project_groups_test.go +++ b/bitbucket/data_project_permission_groups_test.go @@ -9,14 +9,14 @@ import ( "github.com/hashicorp/terraform/helper/resource" ) -func TestAccBitbucketDatProjectGroups_check_empty(t *testing.T) { +func TestAccBitbucketDataProjectPermissionsGroups_check_empty(t *testing.T) { config := fmt.Sprintf(` resource "bitbucketserver_project" "test" { key = "TEST%v" name = "test-repo-for-repository-test" } - data "bitbucketserver_project_groups" "test" { + data "bitbucketserver_project_permissions_groups" "test" { project = bitbucketserver_project.test.key } `, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) @@ -28,7 +28,7 @@ func TestAccBitbucketDatProjectGroups_check_empty(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.bitbucketserver_project_groups.test", "groups.#", "0"), + resource.TestCheckResourceAttr("data.bitbucketserver_project_permissions_groups.test", "groups.#", "0"), ), }, }, diff --git a/bitbucket/provider.go b/bitbucket/provider.go index 731af41..6643e86 100644 --- a/bitbucket/provider.go +++ b/bitbucket/provider.go @@ -29,8 +29,8 @@ func Provider() terraform.ResourceProvider { }, ConfigureFunc: providerConfigure, DataSourcesMap: map[string]*schema.Resource{ - "bitbucketserver_application_properties": dataSourceApplicationProperties(), - "bitbucketserver_project_groups": dataSourceProjectGroups(), + "bitbucketserver_application_properties": dataSourceApplicationProperties(), + "bitbucketserver_project_permissions_groups": dataSourceProjectPermissionsGroups(), }, ResourcesMap: map[string]*schema.Resource{ "bitbucketserver_admin_license": resourceAdminLicense(),