Skip to content

Commit 6df11ac

Browse files
committed
datasource/gitlab_user: Add namespace_id attribute
1 parent a8b65bd commit 6df11ac

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docs/data-sources/user.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ data "gitlab_user" "example-two" {
3838

3939
- `email` (String) The public email address of the user. **Note**: before GitLab 14.8 the lookup was based on the users primary email address.
4040
- `id` (String) The ID of this resource.
41+
- `namespace_id` (Number) The ID of the user's namespace. Requires admin token to access this field. Available since GitLab 14.10.
4142
- `user_id` (Number) The ID of the user.
4243
- `username` (String) The username of the user.
4344

internal/provider/data_source_gitlab_user.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ var _ = registerDataSource("gitlab_user", func() *schema.Resource {
171171
Type: schema.TypeString,
172172
Computed: true,
173173
},
174+
"namespace_id": {
175+
Description: "The ID of the user's namespace. Requires admin token to access this field. Available since GitLab 14.10.",
176+
Type: schema.TypeInt,
177+
Optional: true,
178+
Computed: true,
179+
},
174180
},
175181
}
176182
})
@@ -223,6 +229,7 @@ func dataSourceGitlabUserRead(ctx context.Context, d *schema.ResourceData, meta
223229
return diag.Errorf("one and only one of user_id, username or email must be set")
224230
}
225231

232+
d.SetId(fmt.Sprintf("%d", user.ID))
226233
d.Set("user_id", user.ID)
227234
d.Set("username", user.Username)
228235
d.Set("email", user.Email)
@@ -254,8 +261,7 @@ func dataSourceGitlabUserRead(ctx context.Context, d *schema.ResourceData, meta
254261
d.Set("website_url", user.WebsiteURL)
255262
d.Set("theme_id", user.ThemeID)
256263
d.Set("color_scheme_id", user.ColorSchemeID)
257-
258-
d.SetId(fmt.Sprintf("%d", user.ID))
264+
d.Set("namespace_id", user.NamespaceID)
259265

260266
return nil
261267
}

0 commit comments

Comments
 (0)