Skip to content

Commit 6dd13bd

Browse files
authored
Merge pull request #1173 from timofurrer/feature/gitlab_project_issue_board
New Resource: `gitlab_project_issue_board`
2 parents 7ce0817 + eb3515e commit 6dd13bd

File tree

7 files changed

+881
-0
lines changed

7 files changed

+881
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gitlab_project_issue_board Resource - terraform-provider-gitlab"
4+
subcategory: ""
5+
description: |-
6+
The gitlab_project_issue_board resource allows to manage the lifecycle of a Project Issue Board.
7+
~> NOTE: If the board lists are changed all lists will be recreated.
8+
Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/boards.html
9+
---
10+
11+
# gitlab_project_issue_board (Resource)
12+
13+
The `gitlab_project_issue_board` resource allows to manage the lifecycle of a Project Issue Board.
14+
15+
~> **NOTE:** If the board lists are changed all lists will be recreated.
16+
17+
**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/boards.html)
18+
19+
## Example Usage
20+
21+
```terraform
22+
resource "gitlab_project" "example" {
23+
name = "example project"
24+
description = "Lorem Ipsum"
25+
visibility_level = "public"
26+
}
27+
28+
resource "gitlab_user" "example" {
29+
name = "example"
30+
username = "example"
31+
32+
password = "example1$$$"
33+
}
34+
35+
resource "gitlab_project_membership" "example" {
36+
project_id = gitlab_project.example.id
37+
user_id = gitlab_user.example.id
38+
access_level = "developer"
39+
}
40+
41+
resource "gitlab_project_milestone" "example" {
42+
project = gitlab_project.example.id
43+
title = "m1"
44+
}
45+
46+
resource "gitlab_project_issue_board" "this" {
47+
project = gitlab_project.example.id
48+
name = "Test Issue Board"
49+
50+
lists {
51+
assignee_id = gitlab_user.example.id
52+
}
53+
54+
lists {
55+
milestone_id = gitlab_project_milestone.example.milestone_id
56+
}
57+
58+
depends_on = [
59+
gitlab_project_membership.example
60+
]
61+
}
62+
63+
resource "gitlab_project_issue_board" "list_syntax" {
64+
project = gitlab_project.example.id
65+
name = "Test Issue Board with list syntax"
66+
67+
lists = [
68+
{
69+
assignee_id = gitlab_user.example.id
70+
},
71+
{
72+
milestone_id = gitlab_project_milestone.example.milestone_id
73+
}
74+
]
75+
76+
depends_on = [
77+
gitlab_project_membership.example
78+
]
79+
}
80+
```
81+
82+
<!-- schema generated by tfplugindocs -->
83+
## Schema
84+
85+
### Required
86+
87+
- `name` (String) The name of the board.
88+
- `project` (String) The ID or full path of the project maintained by the authenticated user.
89+
90+
### Optional
91+
92+
- `assignee_id` (Number) The assignee the board should be scoped to. Requires a GitLab EE license.
93+
- `labels` (Set of String) The list of label names which the board should be scoped to. Requires a GitLab EE license.
94+
- `lists` (Block List) The list of issue board lists (see [below for nested schema](#nestedblock--lists))
95+
- `milestone_id` (Number) The milestone the board should be scoped to. Requires a GitLab EE license.
96+
- `weight` (Number) The weight range from 0 to 9, to which the board should be scoped to. Requires a GitLab EE license.
97+
98+
### Read-Only
99+
100+
- `id` (String) The ID of this resource.
101+
102+
<a id="nestedblock--lists"></a>
103+
### Nested Schema for `lists`
104+
105+
Optional:
106+
107+
- `assignee_id` (Number) The ID of the assignee the list should be scoped to. Requires a GitLab EE license.
108+
- `iteration_id` (Number) The ID of the iteration the list should be scoped to. Requires a GitLab EE license.
109+
- `label_id` (Number) The ID of the label the list should be scoped to. Requires a GitLab EE license.
110+
- `milestone_id` (Number) The ID of the milestone the list should be scoped to. Requires a GitLab EE license.
111+
112+
Read-Only:
113+
114+
- `id` (Number) The ID of the list
115+
- `position` (Number) The position of the list within the board. The position for the list is based on the its position in the `lists` array.
116+
117+
## Import
118+
119+
Import is supported using the following syntax:
120+
121+
```shell
122+
# You can import this resource with an id made up of `{project-id}:{issue-board-id}`, e.g.
123+
terraform import gitlab_project_issue_board.kanban 42:1
124+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# You can import this resource with an id made up of `{project-id}:{issue-board-id}`, e.g.
2+
terraform import gitlab_project_issue_board.kanban 42:1
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
resource "gitlab_project" "example" {
2+
name = "example project"
3+
description = "Lorem Ipsum"
4+
visibility_level = "public"
5+
}
6+
7+
resource "gitlab_user" "example" {
8+
name = "example"
9+
username = "example"
10+
11+
password = "example1$$$"
12+
}
13+
14+
resource "gitlab_project_membership" "example" {
15+
project_id = gitlab_project.example.id
16+
user_id = gitlab_user.example.id
17+
access_level = "developer"
18+
}
19+
20+
resource "gitlab_project_milestone" "example" {
21+
project = gitlab_project.example.id
22+
title = "m1"
23+
}
24+
25+
resource "gitlab_project_issue_board" "this" {
26+
project = gitlab_project.example.id
27+
name = "Test Issue Board"
28+
29+
lists {
30+
assignee_id = gitlab_user.example.id
31+
}
32+
33+
lists {
34+
milestone_id = gitlab_project_milestone.example.milestone_id
35+
}
36+
37+
depends_on = [
38+
gitlab_project_membership.example
39+
]
40+
}
41+
42+
resource "gitlab_project_issue_board" "list_syntax" {
43+
project = gitlab_project.example.id
44+
name = "Test Issue Board with list syntax"
45+
46+
lists = [
47+
{
48+
assignee_id = gitlab_user.example.id
49+
},
50+
{
51+
milestone_id = gitlab_project_milestone.example.milestone_id
52+
}
53+
]
54+
55+
depends_on = [
56+
gitlab_project_membership.example
57+
]
58+
}

internal/provider/helper_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,32 @@ func testAccCreateProjectIssues(t *testing.T, pid interface{}, n int) []*gitlab.
363363
return issues
364364
}
365365

366+
func testAccCreateProjectIssueBoard(t *testing.T, pid interface{}) *gitlab.IssueBoard {
367+
t.Helper()
368+
369+
issueBoard, _, err := testGitlabClient.Boards.CreateIssueBoard(pid, &gitlab.CreateIssueBoardOptions{Name: gitlab.String(acctest.RandomWithPrefix("acctest"))})
370+
if err != nil {
371+
t.Fatalf("could not create test issue board: %v", err)
372+
}
373+
374+
return issueBoard
375+
}
376+
377+
func testAccCreateProjectLabels(t *testing.T, pid interface{}, n int) []*gitlab.Label {
378+
t.Helper()
379+
380+
var labels []*gitlab.Label
381+
for i := 0; i < n; i++ {
382+
label, _, err := testGitlabClient.Labels.CreateLabel(pid, &gitlab.CreateLabelOptions{Name: gitlab.String(acctest.RandomWithPrefix("acctest")), Color: gitlab.String("#000000")})
383+
if err != nil {
384+
t.Fatalf("could not create test label: %v", err)
385+
}
386+
labels = append(labels, label)
387+
}
388+
389+
return labels
390+
}
391+
366392
// testAccAddGroupMembers is a test helper for adding users as members of a group.
367393
// It assumes the group will be destroyed at the end of the test and will not cleanup members.
368394
func testAccAddGroupMembers(t *testing.T, gid interface{}, users []*gitlab.User) {

0 commit comments

Comments
 (0)