Skip to content

Commit 0fc2249

Browse files
committed
Add docs and fix ID of gitlab_project_protected_branches
Signed-off-by: Sune Keller <[email protected]>
1 parent e1755e4 commit 0fc2249

File tree

3 files changed

+106
-5
lines changed

3 files changed

+106
-5
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# gitlab\_project\_protected\_branch
2+
3+
Provides details about a specific protected branch in a given project.
4+
5+
## Example Usage
6+
7+
```hcl
8+
data "gitlab_project_protected_branch" "example" {
9+
project_id = 30
10+
name = "main"
11+
}
12+
```
13+
14+
```hcl
15+
data "gitlab_project_protected_branch" "example" {
16+
project_id = "foo/bar/baz"
17+
name = "main"
18+
}
19+
```
20+
21+
## Argument Reference
22+
23+
The following arguments are supported:
24+
25+
* `project_id` - (Required) The integer or path with namespace that uniquely identifies the project.
26+
27+
* `name` - (Required) The name of the protected branch.
28+
29+
## Attributes Reference
30+
31+
The following attributes are exported:
32+
33+
* `push_access_levels`, `merge_access_levels`, `unprotect_access_levels` - Each block contains a list of which access levels, users or groups are allowed to perform the respective actions (documented below).
34+
35+
* `code_owner_approval_required` - Reject code pushes that change files listed in the CODEOWNERS file.
36+
37+
## Nested Blocks
38+
39+
### `push_access_levels`, `merge_access_levels`, `unprotect_access_levels`
40+
41+
#### Attributes
42+
43+
* `access_level` - The access level allowed to perform the respective action (shows as 40 - "maintainer" if `user_id` or `group_id` are present).
44+
45+
* `access_level_description` - A description of the allowed access level(s), or the name of the user or group if `user_id` or `group_id` are present.
46+
47+
* `user_id` - If present, indicates that the user is allowed to perform the respective action.
48+
49+
* `group_id` - If present, indicates that the group is allowed to perform the respective action.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# gitlab\_project\_protected\_branches
2+
3+
Provides details about all protected branches in a given project.
4+
5+
## Example Usage
6+
7+
```hcl
8+
data "gitlab_project_protected_branches" "example" {
9+
project_id = 30
10+
}
11+
```
12+
13+
```hcl
14+
data "gitlab_project_protected_branches" "example" {
15+
project_id = "foo/bar/baz"
16+
}
17+
```
18+
19+
## Argument Reference
20+
21+
The following arguments are supported:
22+
23+
* `project_id` - (Required) The integer or path with namespace that uniquely identifies the project.
24+
25+
## Attributes Reference
26+
27+
The following attributes are exported:
28+
29+
* `protected_branches` - A list of protected branches, as defined below.
30+
31+
## Nested Blocks
32+
33+
### `protected_branches`
34+
35+
* `id` - The ID of the protected branch.
36+
37+
* `name` - The name of the protected branch.
38+
39+
* `push_access_levels`, `merge_access_levels`, `unprotect_access_levels` - Each block contains a list of which access levels, users or groups are allowed to perform the respective actions (documented below).
40+
41+
* `code_owner_approval_required` - Reject code pushes that change files listed in the CODEOWNERS file.
42+
43+
### `push_access_levels`, `merge_access_levels`, `unprotect_access_levels`
44+
45+
#### Attributes
46+
47+
* `access_level` - The access level allowed to perform the respective action (shows as 40 - "maintainer" if `user_id` or `group_id` are present).
48+
49+
* `access_level_description` - A description of the allowed access level(s), or the name of the user or group if `user_id` or `group_id` are present.
50+
51+
* `user_id` - If present, indicates that the user is allowed to perform the respective action.
52+
53+
* `group_id` - If present, indicates that the group is allowed to perform the respective action.

gitlab/data_source_gitlab_project_protected_branches.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ func dataSourceGitlabProjectProtectedBranchesRead(d *schema.ResourceData, meta i
6969

7070
allProtectedBranches := make([]stateProtectedBranch, 0)
7171
totalPages := -1
72-
for page := 0; page != totalPages; page++ {
72+
opts := &gitlab.ListProtectedBranchesOptions{}
73+
for opts.Page = 0; opts.Page != totalPages; opts.Page++ {
7374
// Get protected branch by project ID/path and branch name
74-
pbs, resp, err := client.ProtectedBranches.ListProtectedBranches(project, &gitlab.ListProtectedBranchesOptions{
75-
Page: page + 1,
76-
})
75+
pbs, resp, err := client.ProtectedBranches.ListProtectedBranches(project, opts)
7776
if err != nil {
7877
return err
7978
}
@@ -94,7 +93,7 @@ func dataSourceGitlabProjectProtectedBranchesRead(d *schema.ResourceData, meta i
9493
return err
9594
}
9695

97-
h, err := hashstructure.Hash(project, nil)
96+
h, err := hashstructure.Hash(*opts, nil)
9897
if err != nil {
9998
return err
10099
}

0 commit comments

Comments
 (0)