Skip to content

Commit 13a8415

Browse files
authored
Merge pull request #654 from willianpaixao/master
More examples and better documentation
2 parents b3e5bf8 + e6e4601 commit 13a8415

File tree

6 files changed

+69
-23
lines changed

6 files changed

+69
-23
lines changed

docs/data-sources/user.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gitlab\_user
22

3-
Provides details about a specific user in the gitlab provider. Especially the ability to lookup the id for linking to other resources.
3+
Provide details about a specific user in the gitlab provider. Especially the ability to lookup the id for linking to other resources.
44

55
## Example Usage
66

@@ -10,6 +10,16 @@ data "gitlab_user" "example" {
1010
}
1111
```
1212

13+
### Example using `for_each`
14+
15+
```hcl
16+
data "gitlab_user" "example-two" {
17+
for_each = toset(["user1", "user2", "user3"])
18+
19+
username = each.value
20+
}
21+
```
22+
1323
## Argument Reference
1424

1525
The following arguments are supported:
@@ -20,7 +30,7 @@ The following arguments are supported:
2030

2131
* `user_id` - (Optional) The ID of the user.
2232

23-
**Note**: only one of email, user_id or username must be provided.
33+
-> Only one of email, user_id, or username must be provided.
2434

2535
## Attributes Reference
2636

@@ -52,7 +62,7 @@ The following arguments are supported:
5262

5363
* `organization` - The organization of the user.
5464

55-
* `two_factor_enabled` - Whether user's two factor auth is enabled.
65+
* `two_factor_enabled` - Whether user's two-factor auth is enabled.
5666

5767
* `avatar_url` - The avatar URL of the user.
5868

@@ -62,7 +72,7 @@ The following arguments are supported:
6272

6373
* `skype` - Skype username of the user.
6474

65-
* `linkedin` - Linkedin profile of the user.
75+
* `linkedin` - LinkedIn profile of the user.
6676

6777
* `twitter` - Twitter username of the user.
6878

@@ -76,6 +86,4 @@ The following arguments are supported:
7686

7787
* `current_sign_in_at` - Current user's sign-in date.
7888

79-
**Note**: some attributes might not be returned depending on if you're an admin or not. Please refer to [doc][doc] for more details.
80-
81-
[doc]: https://docs.gitlab.com/ce/api/users.html#single-user
89+
-> Some attributes might not be returned depending on if you're an admin or not. Please refer to [Gitlab documentation](https://docs.gitlab.com/ce/api/users.html#single-user) for more details.

docs/resources/branch_protection.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This resource allows you to protect a specific branch by an access level so that the user with less access level cannot Merge/Push to the branch.
44

5-
-> The `allowed_to_push`, `allowed_to_merge` and `code_owner_approval_required` arguments require a GitLab Premium account or above.
5+
-> The `allowed_to_push`, `allowed_to_merge` and `code_owner_approval_required` arguments require a GitLab Premium account or above. Please refer to [Gitlab API documentation](https://docs.gitlab.com/ee/api/protected_branches.html) for further information.
66

77
## Example Usage
88

@@ -28,6 +28,24 @@ resource "gitlab_branch_protection" "BranchProtect" {
2828
}
2929
```
3030

31+
### Example using dynamic block
32+
33+
```hcl
34+
resource "gitlab_branch_protection" "main" {
35+
project = "12345"
36+
branch = "main"
37+
push_access_level = "maintainer"
38+
merge_access_level = "maintainer"
39+
40+
dynamic "allowed_to_push" {
41+
for_each = [50, 55, 60]
42+
content {
43+
user_id = allowed_to_push.value
44+
}
45+
}
46+
}
47+
```
48+
3149
## Argument Reference
3250

3351
The following arguments are supported:
@@ -62,7 +80,7 @@ The following attributes are exported:
6280

6381
## Import
6482

65-
GitLab project freeze periods can be imported using an id made up of `project_id:branch`, e.g.
83+
Gitlab protected branches can be imported with a key composed of `<project_id>:<branch>`, e.g.
6684

6785
```
6886
$ terraform import gitlab_branch_protection.BranchProtect "12345:main"

docs/resources/deploy_token.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gitlab\_deploy\_token
22

3-
This resource allows you to create and manage deploy token for your GitLab projects and groups.
3+
This resource allows you to create and manage deploy token for your GitLab projects and groups. Please refer to [Gitlab documentation](https://docs.gitlab.com/ee/user/project/deploy_tokens/) for further information.
44

55
## Example Usage - Project
66

@@ -13,6 +13,12 @@ resource "gitlab_deploy_token" "example" {
1313
1414
scopes = [ "read_repository", "read_registry" ]
1515
}
16+
17+
resource "gitlab_deploy_token" "example-two" {
18+
project = "12345678"
19+
name = "Example deploy token expires in 24h"
20+
expires_at = timeadd(timestamp(), "24h")
21+
}
1622
```
1723

1824
## Example Usage - Group
@@ -21,7 +27,7 @@ resource "gitlab_deploy_token" "example" {
2127
resource "gitlab_deploy_token" "example" {
2228
group = "example/deploying"
2329
name = "Example group deploy token"
24-
30+
2531
scopes = [ "read_repository" ]
2632
}
2733
```

docs/resources/project_approval_rule.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# gitlab\_project\_approval\_rule
22

3-
This resource allows you to create and manage multiple approval rules for your GitLab
4-
projects. For further information on approval rules, consult the [gitlab
5-
documentation](https://docs.gitlab.com/ee/api/merge_request_approvals.html#project-level-mr-approvals).
3+
This resource allows you to create and manage multiple approval rules for your GitLab projects. For further information on approval rules, consult the [gitlab documentation](https://docs.gitlab.com/ee/api/merge_request_approvals.html#project-level-mr-approvals).
64

75
-> This feature requires GitLab Premium.
86

@@ -28,16 +26,33 @@ resource "gitlab_branch_protection" "example" {
2826
merge_access_level = "developer"
2927
}
3028
31-
resource "gitlab_project_approval_rule" "example" {
29+
resource "gitlab_project_approval_rule" "example-two" {
3230
project = 5
33-
name = "Example Rule"
31+
name = "Example Rule 2"
3432
approvals_required = 3
3533
user_ids = [50, 500]
3634
group_ids = [51]
3735
protected_branch_ids = [gitlab_branch_protection.example.branch_protection_id]
3836
}
3937
```
4038

39+
### Example using `data.gitlab_user` and `for` loop
40+
41+
```hcl
42+
data "gitlab_user" "users" {
43+
for_each = toset(["user1", "user2", "user3"])
44+
45+
username = each.value
46+
}
47+
48+
resource "gitlab_project_approval_rule" "example-three" {
49+
project = 5
50+
name = "Example Rule 3"
51+
approvals_required = 3
52+
user_ids = [for user in data.gitlab_user.users : user.id]
53+
}
54+
```
55+
4156
## Argument Reference
4257

4358
The following arguments are supported:
@@ -56,7 +71,7 @@ The following arguments are supported:
5671

5772
## Import
5873

59-
GitLab project approval rules can be imported using an id consisting of `project-id:rule-id`, e.g.
74+
GitLab project approval rules can be imported using a key composed of `<project-id>:<rule-id>`, e.g.
6075

6176
```
6277
$ terraform import gitlab_project_approval_rule.example "12345:6"

docs/resources/project_level_mr_approvals.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# gitlab\_project\_level\_mr\_approvals
22

33
This resource allows you to configure project-level MR approvals. for your GitLab projects.
4-
For further information on merge request approvals, consult the [GitLab API
5-
documentation](https://docs.gitlab.com/ee/api/merge_request_approvals.html#project-level-mr-approvals).
4+
For further information on merge request approvals, consult the [GitLab API documentation](https://docs.gitlab.com/ee/api/merge_request_approvals.html#project-level-mr-approvals).
65

76
## Example Usage
87

@@ -39,10 +38,10 @@ also need to be included in the approvers list in order to be able to approve th
3938

4039
## Import
4140

42-
You can import an approval configuration state using `terraform import <resource> <project_id>`.
41+
You can import an approval configuration state using `terraform import <resource> <project_id>:<approval_rule_id>`.
4342

4443
For example:
4544

4645
```
47-
$ terraform import gitlab_project_level_mr_approvals.foo 53
46+
$ terraform import gitlab_project_level_mr_approvals.foo 1234:53
4847
```

docs/resources/user.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This resource allows you to create and manage GitLab users.
44
Note your provider will need to be configured with admin-level access for this resource to work.
55

6-
-> **Note:** You must specify either `password` or `reset_password`.
6+
-> You must specify either `password` or `reset_password`.
77

88
## Example Usage
99

@@ -33,7 +33,7 @@ The following arguments are supported:
3333

3434
* `password` - (Optional) The password of the user.
3535

36-
* `is_admin` - (Optional) Boolean, defaults to false. Whether to enable administrative priviledges
36+
* `is_admin` - (Optional) Boolean, defaults to false. Whether to enable administrative privileges
3737
for the user.
3838

3939
* `projects_limit` - (Optional) Integer, defaults to 0. Number of projects user can create.

0 commit comments

Comments
 (0)