Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: gitlab_project_issue_board #1173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
124 changes: 124 additions & 0 deletions docs/resources/project_issue_board.md
@@ -0,0 +1,124 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gitlab_project_issue_board Resource - terraform-provider-gitlab"
subcategory: ""
description: |-
The gitlab_project_issue_board resource allows to manage the lifecycle of a Project Issue Board.
~> NOTE: If the board lists are changed all lists will be recreated.
Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/boards.html
---

# gitlab_project_issue_board (Resource)

The `gitlab_project_issue_board` resource allows to manage the lifecycle of a Project Issue Board.

~> **NOTE:** If the board lists are changed all lists will be recreated.

**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/boards.html)

## Example Usage

```terraform
resource "gitlab_project" "example" {
name = "example project"
description = "Lorem Ipsum"
visibility_level = "public"
}
resource "gitlab_user" "example" {
name = "example"
username = "example"
email = "example@example.com"
password = "example1$$$"
}
resource "gitlab_project_membership" "example" {
project_id = gitlab_project.example.id
user_id = gitlab_user.example.id
access_level = "developer"
}
resource "gitlab_project_milestone" "example" {
project = gitlab_project.example.id
title = "m1"
}
resource "gitlab_project_issue_board" "this" {
project = gitlab_project.example.id
name = "Test Issue Board"
lists {
assignee_id = gitlab_user.example.id
}
lists {
milestone_id = gitlab_project_milestone.example.milestone_id
}
depends_on = [
gitlab_project_membership.example
]
}
resource "gitlab_project_issue_board" "list_syntax" {
project = gitlab_project.example.id
name = "Test Issue Board with list syntax"
lists = [
{
assignee_id = gitlab_user.example.id
},
{
milestone_id = gitlab_project_milestone.example.milestone_id
}
]
depends_on = [
gitlab_project_membership.example
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the board.
- `project` (String) The ID or full path of the project maintained by the authenticated user.

### Optional

- `assignee_id` (Number) The assignee the board should be scoped to. Requires a GitLab EE license.
- `labels` (Set of String) The list of label names which the board should be scoped to. Requires a GitLab EE license.
- `lists` (Block List) The list of issue board lists (see [below for nested schema](#nestedblock--lists))
- `milestone_id` (Number) The milestone the board should be scoped to. Requires a GitLab EE license.
- `weight` (Number) The weight range from 0 to 9, to which the board should be scoped to. Requires a GitLab EE license.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--lists"></a>
### Nested Schema for `lists`

Optional:

- `assignee_id` (Number) The ID of the assignee the list should be scoped to. Requires a GitLab EE license.
- `iteration_id` (Number) The ID of the iteration the list should be scoped to. Requires a GitLab EE license.
- `label_id` (Number) The ID of the label the list should be scoped to. Requires a GitLab EE license.
- `milestone_id` (Number) The ID of the milestone the list should be scoped to. Requires a GitLab EE license.

Read-Only:

- `id` (Number) The ID of the list
- `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.

## Import

Import is supported using the following syntax:

```shell
# You can import this resource with an id made up of `{project-id}:{issue-board-id}`, e.g.
terraform import gitlab_project_issue_board.kanban 42:1
```
2 changes: 2 additions & 0 deletions examples/resources/gitlab_project_issue_board/import.sh
@@ -0,0 +1,2 @@
# You can import this resource with an id made up of `{project-id}:{issue-board-id}`, e.g.
terraform import gitlab_project_issue_board.kanban 42:1
58 changes: 58 additions & 0 deletions examples/resources/gitlab_project_issue_board/resource.tf
@@ -0,0 +1,58 @@
resource "gitlab_project" "example" {
name = "example project"
description = "Lorem Ipsum"
visibility_level = "public"
}

resource "gitlab_user" "example" {
name = "example"
username = "example"
email = "example@example.com"
password = "example1$$$"
}

resource "gitlab_project_membership" "example" {
project_id = gitlab_project.example.id
user_id = gitlab_user.example.id
access_level = "developer"
}

resource "gitlab_project_milestone" "example" {
project = gitlab_project.example.id
title = "m1"
}

resource "gitlab_project_issue_board" "this" {
project = gitlab_project.example.id
name = "Test Issue Board"

lists {
assignee_id = gitlab_user.example.id
}

lists {
milestone_id = gitlab_project_milestone.example.milestone_id
}

depends_on = [
gitlab_project_membership.example
]
}

resource "gitlab_project_issue_board" "list_syntax" {
project = gitlab_project.example.id
name = "Test Issue Board with list syntax"

lists = [
{
assignee_id = gitlab_user.example.id
},
{
milestone_id = gitlab_project_milestone.example.milestone_id
}
]

depends_on = [
gitlab_project_membership.example
]
}
26 changes: 26 additions & 0 deletions internal/provider/helper_test.go
Expand Up @@ -363,6 +363,32 @@ func testAccCreateProjectIssues(t *testing.T, pid interface{}, n int) []*gitlab.
return issues
}

func testAccCreateProjectIssueBoard(t *testing.T, pid interface{}) *gitlab.IssueBoard {
t.Helper()

issueBoard, _, err := testGitlabClient.Boards.CreateIssueBoard(pid, &gitlab.CreateIssueBoardOptions{Name: gitlab.String(acctest.RandomWithPrefix("acctest"))})
if err != nil {
t.Fatalf("could not create test issue board: %v", err)
}

return issueBoard
}

func testAccCreateProjectLabels(t *testing.T, pid interface{}, n int) []*gitlab.Label {
t.Helper()

var labels []*gitlab.Label
for i := 0; i < n; i++ {
label, _, err := testGitlabClient.Labels.CreateLabel(pid, &gitlab.CreateLabelOptions{Name: gitlab.String(acctest.RandomWithPrefix("acctest")), Color: gitlab.String("#000000")})
if err != nil {
t.Fatalf("could not create test label: %v", err)
}
labels = append(labels, label)
}

return labels
}

// testAccAddGroupMembers is a test helper for adding users as members of a group.
// It assumes the group will be destroyed at the end of the test and will not cleanup members.
func testAccAddGroupMembers(t *testing.T, gid interface{}, users []*gitlab.User) {
Expand Down