Skip to content

Commit ffca640

Browse files
committed
password and reset_password are exclusive
1 parent f60dc34 commit ffca640

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gitlab/resource_gitlab_user.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ func resourceGitlabUserCreate(d *schema.ResourceData, meta interface{}) error {
109109
ResetPassword: gitlab.Bool(d.Get("reset_password").(bool)),
110110
}
111111

112+
if *options.Password == "" && !*options.ResetPassword {
113+
return fmt.Errorf("At least one of either password or reset_password must be defined")
114+
}
115+
112116
log.Printf("[DEBUG] create gitlab user %q", *options.Username)
113117

114118
user, _, err := client.Users.CreateUser(options)

website/docs/r/user.html.markdown

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111
This resource allows you to create and manage GitLab users.
1212
Note your provider will need to be configured with admin-level access for this resource to work.
1313

14+
-> **Note:** You must specify either `password` or `reset_password`.
15+
1416
## Example Usage
1517

1618
```hcl
@@ -35,10 +37,10 @@ The following arguments are supported:
3537

3638
* `username` - (Required) The username of the user.
3739

38-
* `password` - (Required) The password of the user.
39-
4040
* `email` - (Required) The e-mail address of the user.
4141

42+
* `password` - (Optional) The password of the user.
43+
4244
* `is_admin` - (Optional) Boolean, defaults to false. Whether to enable administrative priviledges
4345
for the user.
4446

0 commit comments

Comments
 (0)