Skip to content

Commit 2e1036d

Browse files
authored
Merge pull request #54 from adam-janis/testy
users: add is_external attribute
2 parents 3156239 + 3c5703e commit 2e1036d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+8578
-1187
lines changed

gitlab/resource_gitlab_label.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func resourceGitlabLabelRead(d *schema.ResourceData, meta interface{}) error {
6666
labelName := d.Id()
6767
log.Printf("[DEBUG] read gitlab label %s/%s", project, labelName)
6868

69-
labels, response, err := client.Labels.ListLabels(project)
69+
labels, response, err := client.Labels.ListLabels(project, nil)
7070
if err != nil {
7171
if response.StatusCode == 404 {
7272
log.Printf("[WARN] removing label %s from state because it no longer exists in gitlab", labelName)

gitlab/resource_gitlab_label_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func testAccCheckGitlabLabelExists(n string, label *gitlab.Label) resource.TestC
7373
}
7474
conn := testAccProvider.Meta().(*gitlab.Client)
7575

76-
labels, _, err := conn.Labels.ListLabels(repoName)
76+
labels, _, err := conn.Labels.ListLabels(repoName, nil)
7777
if err != nil {
7878
return err
7979
}

gitlab/resource_gitlab_user.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ func resourceGitlabUser() *schema.Resource {
5858
Optional: true,
5959
Default: 0,
6060
},
61+
"is_external": {
62+
Type: schema.TypeBool,
63+
Optional: true,
64+
Default: false,
65+
},
6166
},
6267
}
6368
}
@@ -80,6 +85,7 @@ func resourceGitlabUserCreate(d *schema.ResourceData, meta interface{}) error {
8085
Admin: gitlab.Bool(d.Get("is_admin").(bool)),
8186
CanCreateGroup: gitlab.Bool(d.Get("can_create_group").(bool)),
8287
SkipConfirmation: gitlab.Bool(d.Get("skip_confirmation").(bool)),
88+
External: gitlab.Bool(d.Get("is_external").(bool)),
8389
}
8490

8591
log.Printf("[DEBUG] create gitlab user %q", options.Username)
@@ -91,6 +97,7 @@ func resourceGitlabUserCreate(d *schema.ResourceData, meta interface{}) error {
9197

9298
d.SetId(fmt.Sprintf("%d", user.ID))
9399
d.Set("is_admin", user.IsAdmin)
100+
d.Set("is_external", user.External)
94101

95102
return resourceGitlabUserRead(d, meta)
96103
}
@@ -141,6 +148,10 @@ func resourceGitlabUserUpdate(d *schema.ResourceData, meta interface{}) error {
141148
options.ProjectsLimit = gitlab.Int(d.Get("projects_limit").(int))
142149
}
143150

151+
if d.HasChange("is_external") {
152+
options.Admin = gitlab.Bool(d.Get("is_external").(bool))
153+
}
154+
144155
log.Printf("[DEBUG] update gitlab user %s", d.Id())
145156

146157
id, _ := strconv.Atoi(d.Id())

gitlab/resource_gitlab_user_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
3434
Admin: false,
3535
CanCreateGroup: false,
3636
SkipConfirmation: true,
37+
External: false,
3738
}),
3839
),
3940
},
@@ -51,6 +52,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
5152
Admin: true,
5253
CanCreateGroup: true,
5354
SkipConfirmation: false,
55+
External: true,
5456
}),
5557
),
5658
},
@@ -68,6 +70,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
6870
Admin: false,
6971
CanCreateGroup: false,
7072
SkipConfirmation: false,
73+
External: false,
7174
}),
7275
),
7376
},
@@ -108,6 +111,7 @@ type testAccGitlabUserExpectedAttributes struct {
108111
Admin bool
109112
CanCreateGroup bool
110113
SkipConfirmation bool
114+
External bool
111115
}
112116

113117
func testAccCheckGitlabUserAttributes(user *gitlab.User, want *testAccGitlabUserExpectedAttributes) resource.TestCheckFunc {
@@ -158,6 +162,7 @@ resource "gitlab_user" "foo" {
158162
is_admin = false
159163
projects_limit = 0
160164
can_create_group = false
165+
is_external = false
161166
}
162167
`, rInt, rInt, rInt, rInt)
163168
}
@@ -172,6 +177,7 @@ resource "gitlab_user" "foo" {
172177
is_admin = true
173178
projects_limit = 10
174179
can_create_group = true
180+
is_external = true
175181
}
176182
`, rInt, rInt, rInt, rInt)
177183
}

vendor/github.com/xanzy/go-gitlab/README.md

Lines changed: 66 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)