Skip to content

Commit 0a261de

Browse files
author
Jordan Caussat
committed
Update project shared_with_groups: change type from TypeList to TypeSet
1 parent be4666c commit 0a261de

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

gitlab/resource_gitlab_project.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func resourceGitlabProject() *schema.Resource {
9494
Computed: true,
9595
},
9696
"shared_with_groups": {
97-
Type: schema.TypeList,
97+
Type: schema.TypeSet,
9898
Optional: true,
9999
Elem: &schema.Resource{
100100
Schema: map[string]*schema.Schema{
@@ -170,7 +170,7 @@ func resourceGitlabProjectCreate(d *schema.ResourceData, meta interface{}) error
170170
}
171171

172172
if v, ok := d.GetOk("shared_with_groups"); ok {
173-
options := expandSharedWithGroupsOptions(v.([]interface{}))
173+
options := expandSharedWithGroupsOptions(v)
174174

175175
for _, option := range options {
176176
_, err := client.Projects.ShareProjectWithGroup(project.ID, option)
@@ -298,10 +298,10 @@ func resourceGitlabProjectDelete(d *schema.ResourceData, meta interface{}) error
298298
return nil
299299
}
300300

301-
func expandSharedWithGroupsOptions(d []interface{}) []*gitlab.ShareWithGroupOptions {
301+
func expandSharedWithGroupsOptions(v interface{}) []*gitlab.ShareWithGroupOptions {
302302
shareWithGroupOptionsList := []*gitlab.ShareWithGroupOptions{}
303303

304-
for _, config := range d {
304+
for _, config := range v.(*schema.Set).List() {
305305
data := config.(map[string]interface{})
306306

307307
groupAccess := accessLevelNameToValue[data["group_access_level"].(string)]
@@ -368,8 +368,7 @@ func updateSharedWithGroups(d *schema.ResourceData, meta interface{}) error {
368368
var groupsToShare []*gitlab.ShareWithGroupOptions
369369

370370
// Get target groups from the TF config and current groups from Gitlab server
371-
targetGroups := expandSharedWithGroupsOptions(
372-
d.Get("shared_with_groups").([]interface{}))
371+
targetGroups := expandSharedWithGroupsOptions(d.Get("shared_with_groups"))
373372
project, _, err := client.Projects.GetProject(d.Id())
374373
if err != nil {
375374
return err

gitlab/resource_gitlab_project_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
106106
GroupID int
107107
GroupName string
108108
GroupAccessLevel int
109-
}{{0, "", 10}, {0, "", 30}},
109+
}{{0, "", 30}, {0, "", 10}},
110110
}),
111111
),
112112
},

0 commit comments

Comments
 (0)