Skip to content

Commit a8b65bd

Browse files
committed
resource/gitlab_user: Add namespace_id attribute
1 parent 67c7783 commit a8b65bd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

docs/resources/user.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ resource "gitlab_user" "example" {
5050
- `id` (String) The ID of this resource.
5151
- `is_admin` (Boolean) Boolean, defaults to false. Whether to enable administrative privileges
5252
- `is_external` (Boolean) Boolean, defaults to false. Whether a user has access only to some internal or private projects. External users can only access projects to which they are explicitly granted access.
53+
- `namespace_id` (Number) The ID of the user's namespace. Available since GitLab 14.10.
5354
- `note` (String) The note associated to the user.
5455
- `password` (String, Sensitive) The password of the user.
5556
- `projects_limit` (Number) Integer, defaults to 0. Number of projects user can create.

internal/provider/resource_gitlab_user.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ var _ = registerResource("gitlab_user", func() *schema.Resource {
110110
Default: "active",
111111
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(validUserStateValues, false)),
112112
},
113+
"namespace_id": {
114+
Description: "The ID of the user's namespace. Available since GitLab 14.10.",
115+
Type: schema.TypeInt,
116+
Optional: true,
117+
Computed: true,
118+
},
113119
},
114120
}
115121
})
@@ -124,6 +130,7 @@ func resourceGitlabUserSetToState(d *schema.ResourceData, user *gitlab.User) {
124130
d.Set("is_external", user.External)
125131
d.Set("note", user.Note)
126132
d.Set("state", user.State)
133+
d.Set("namespace_id", user.NamespaceID)
127134
}
128135

129136
func resourceGitlabUserCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

internal/provider/resource_gitlab_user_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
3030
Email: fmt.Sprintf("listest%[email protected]", rInt),
3131
Username: fmt.Sprintf("listest%d", rInt),
3232
Name: fmt.Sprintf("foo %d", rInt),
33+
NamespaceID: user.NamespaceID,
3334
ProjectsLimit: 0,
3435
Admin: false,
3536
CanCreateGroup: false,
@@ -56,6 +57,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
5657
Email: fmt.Sprintf("listest%[email protected]", rInt),
5758
Username: fmt.Sprintf("listest%d", rInt),
5859
Name: fmt.Sprintf("foo %d", rInt),
60+
NamespaceID: user.NamespaceID,
5961
ProjectsLimit: 0,
6062
Admin: false,
6163
CanCreateGroup: false,
@@ -82,6 +84,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
8284
Email: fmt.Sprintf("listest%[email protected]", rInt),
8385
Username: fmt.Sprintf("listest%d", rInt),
8486
Name: fmt.Sprintf("bar %d", rInt),
87+
NamespaceID: user.NamespaceID,
8588
ProjectsLimit: 10,
8689
Admin: true,
8790
CanCreateGroup: true,
@@ -109,6 +112,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
109112
Email: fmt.Sprintf("listest%[email protected]", rInt),
110113
Username: fmt.Sprintf("listest%d", rInt),
111114
Name: fmt.Sprintf("bar %d", rInt),
115+
NamespaceID: user.NamespaceID,
112116
ProjectsLimit: 10,
113117
Admin: true,
114118
CanCreateGroup: true,
@@ -136,6 +140,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
136140
Email: fmt.Sprintf("listest%[email protected]", rInt),
137141
Username: fmt.Sprintf("listest%d", rInt),
138142
Name: fmt.Sprintf("foo %d", rInt),
143+
NamespaceID: user.NamespaceID,
139144
ProjectsLimit: 0,
140145
Admin: false,
141146
CanCreateGroup: false,
@@ -162,6 +167,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
162167
Email: fmt.Sprintf("listest%[email protected]", rInt),
163168
Username: fmt.Sprintf("listest%d", rInt),
164169
Name: fmt.Sprintf("foo %d", rInt),
170+
NamespaceID: user.NamespaceID,
165171
ProjectsLimit: 0,
166172
Admin: false,
167173
CanCreateGroup: false,
@@ -188,6 +194,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
188194
Email: fmt.Sprintf("listest%[email protected]", rInt),
189195
Username: fmt.Sprintf("listest%d", rInt),
190196
Name: fmt.Sprintf("foo %d", rInt),
197+
NamespaceID: user.NamespaceID,
191198
ProjectsLimit: 0,
192199
Admin: false,
193200
CanCreateGroup: false,
@@ -214,6 +221,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
214221
Email: fmt.Sprintf("listest%[email protected]", rInt),
215222
Username: fmt.Sprintf("listest%d", rInt),
216223
Name: fmt.Sprintf("foo %d", rInt),
224+
NamespaceID: user.NamespaceID,
217225
ProjectsLimit: 0,
218226
Admin: false,
219227
CanCreateGroup: false,
@@ -231,6 +239,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
231239
Email: fmt.Sprintf("listest%[email protected]", rInt),
232240
Username: fmt.Sprintf("listest%d", rInt),
233241
Name: fmt.Sprintf("foo %d", rInt),
242+
NamespaceID: user.NamespaceID,
234243
ProjectsLimit: 0,
235244
Admin: false,
236245
CanCreateGroup: false,
@@ -248,6 +257,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
248257
Email: fmt.Sprintf("listest%[email protected]", rInt),
249258
Username: fmt.Sprintf("listest%d", rInt),
250259
Name: fmt.Sprintf("foo %d", rInt),
260+
NamespaceID: user.NamespaceID,
251261
ProjectsLimit: 0,
252262
Admin: false,
253263
CanCreateGroup: false,
@@ -265,6 +275,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
265275
Email: fmt.Sprintf("listest%[email protected]", rInt),
266276
Username: fmt.Sprintf("listest%d", rInt),
267277
Name: fmt.Sprintf("foo %d", rInt),
278+
NamespaceID: user.NamespaceID,
268279
ProjectsLimit: 0,
269280
Admin: false,
270281
CanCreateGroup: false,
@@ -282,6 +293,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
282293
Email: fmt.Sprintf("listest%[email protected]", rInt),
283294
Username: fmt.Sprintf("listest%d", rInt),
284295
Name: fmt.Sprintf("foo %d", rInt),
296+
NamespaceID: user.NamespaceID,
285297
ProjectsLimit: 0,
286298
Admin: false,
287299
CanCreateGroup: false,
@@ -299,6 +311,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
299311
Email: fmt.Sprintf("listest%[email protected]", rInt),
300312
Username: fmt.Sprintf("listest%d", rInt),
301313
Name: fmt.Sprintf("foo %d", rInt),
314+
NamespaceID: user.NamespaceID,
302315
ProjectsLimit: 0,
303316
Admin: false,
304317
CanCreateGroup: false,
@@ -370,6 +383,7 @@ type testAccGitlabUserExpectedAttributes struct {
370383
Email string
371384
Username string
372385
Name string
386+
NamespaceID int
373387
ProjectsLimit int
374388
Admin bool
375389
CanCreateGroup bool

0 commit comments

Comments
 (0)