Skip to content

Commit ae5d917

Browse files
committed
Allow to change user email address without creating a new resource
1 parent 2ae4d9e commit ae5d917

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

gitlab/resource_gitlab_user.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func resourceGitlabUser() *schema.Resource {
4848
"email": {
4949
Type: schema.TypeString,
5050
Required: true,
51-
ForceNew: true,
5251
},
5352
"name": {
5453
Type: schema.TypeString,
@@ -153,6 +152,11 @@ func resourceGitlabUserUpdate(d *schema.ResourceData, meta interface{}) error {
153152
options.Username = gitlab.String(d.Get("username").(string))
154153
}
155154

155+
if d.HasChange("email") {
156+
options.Email = gitlab.String(d.Get("email").(string))
157+
options.SkipReconfirmation = gitlab.Bool(true)
158+
}
159+
156160
if d.HasChange("is_admin") {
157161
options.Admin = gitlab.Bool(d.Get("is_admin").(bool))
158162
}

gitlab/resource_gitlab_user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
4444
Check: resource.ComposeTestCheckFunc(
4545
testAccCheckGitlabUserExists("gitlab_user.foo", &user),
4646
testAccCheckGitlabUserAttributes(&user, &testAccGitlabUserExpectedAttributes{
47-
Email: fmt.Sprintf("listest%d@ssss.com", rInt),
47+
Email: fmt.Sprintf("listest%d@tttt.com", rInt),
4848
Password: fmt.Sprintf("test%dtt", rInt),
4949
Username: fmt.Sprintf("listest%d", rInt),
5050
Name: fmt.Sprintf("bar %d", rInt),
@@ -220,7 +220,7 @@ resource "gitlab_user" "foo" {
220220
name = "bar %d"
221221
username = "listest%d"
222222
password = "test%dtt"
223-
email = "listest%d@ssss.com"
223+
email = "listest%d@tttt.com"
224224
is_admin = true
225225
projects_limit = 10
226226
can_create_group = true

0 commit comments

Comments
 (0)