Skip to content

Commit 210ba84

Browse files
authored
Merge pull request #891 from timofurrer/feature/gitlab-project-issue-746
Add initial Gitlab Project Issue resource and data source support
2 parents e5b66fc + d2ff505 commit 210ba84

16 files changed

+2064
-1
lines changed

docs/data-sources/project_issue.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gitlab_project_issue Data Source - terraform-provider-gitlab"
4+
subcategory: ""
5+
description: |-
6+
The gitlab_project_issue data source allows to retrieve details about an issue in a project.
7+
Upstream API: GitLab API docs https://docs.gitlab.com/ee/api/issues.html
8+
---
9+
10+
# gitlab_project_issue (Data Source)
11+
12+
The `gitlab_project_issue` data source allows to retrieve details about an issue in a project.
13+
14+
**Upstream API:** [GitLab API docs](https://docs.gitlab.com/ee/api/issues.html)
15+
16+
## Example Usage
17+
18+
```terraform
19+
data "gitlab_project" "foo" {
20+
id = "foo/bar/baz"
21+
}
22+
23+
data "gitlab_project_issue" "welcome_issue" {
24+
project = data.gitlab_project.foo.id
25+
iid = 1
26+
}
27+
28+
output "welcome_issue_web_url" {
29+
value = data.gitlab_project_issue.web_url
30+
}
31+
```
32+
33+
<!-- schema generated by tfplugindocs -->
34+
## Schema
35+
36+
### Required
37+
38+
- **iid** (Number) The internal ID of the project's issue.
39+
- **project** (String) The name or ID of the project.
40+
41+
### Optional
42+
43+
- **id** (String) The ID of this resource.
44+
45+
### Read-Only
46+
47+
- **assignee_ids** (Set of Number) The IDs of the users to assign the issue to.
48+
- **author_id** (Number) The ID of the author of the issue. Use `gitlab_user` data source to get more information about the user.
49+
- **closed_at** (String) When the issue was closed. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
50+
- **closed_by_user_id** (Number) The ID of the user that closed the issue. Use `gitlab_user` data source to get more information about the user.
51+
- **confidential** (Boolean) Set an issue to be confidential.
52+
- **created_at** (String) When the issue was created. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z. Requires administrator or project/group owner rights.
53+
- **description** (String) The description of an issue. Limited to 1,048,576 characters.
54+
- **discussion_locked** (Boolean) Whether the issue is locked for discussions or not.
55+
- **discussion_to_resolve** (String) The ID of a discussion to resolve. This fills out the issue with a default description and mark the discussion as resolved. Use in combination with merge_request_to_resolve_discussions_of.
56+
- **downvotes** (Number) The number of downvotes the issue has received.
57+
- **due_date** (String) The due date. Date time string in the format YYYY-MM-DD, for example 2016-03-11.
58+
**Note:** removing a due date is currently not supported, see https://github.com/xanzy/go-gitlab/issues/1384 for details.
59+
- **epic_id** (Number) ID of the epic to add the issue to. Valid values are greater than or equal to 0.
60+
- **epic_issue_id** (Number) The ID of the epic issue.
61+
- **external_id** (String) The external ID of the issue.
62+
- **human_time_estimate** (String) The human-readable time estimate of the issue.
63+
- **human_total_time_spent** (String) The human-readable total time spent of the issue.
64+
- **issue_id** (Number) The instance-wide ID of the issue.
65+
- **issue_link_id** (Number) The ID of the issue link.
66+
- **issue_type** (String) The type of issue. Valid values are: `issue`, `incident`, `test_case`.
67+
- **labels** (Set of String) The labels of an issue.
68+
- **links** (Map of String) The links of the issue.
69+
- **merge_request_to_resolve_discussions_of** (Number) The IID of a merge request in which to resolve all issues. This fills out the issue with a default description and mark all discussions as resolved. When passing a description or title, these values take precedence over the default values.
70+
- **merge_requests_count** (Number) The number of merge requests associated with the issue.
71+
- **milestone_id** (Number) The global ID of a milestone to assign issue. To find the milestone_id associated with a milestone, view an issue with the milestone assigned and use the API to retrieve the issue's details.
72+
- **moved_to_id** (Number) The ID of the issue that was moved to.
73+
- **references** (Map of String) The references of the issue.
74+
- **state** (String) The state of the issue. Valid values are: `opened`, `closed`.
75+
- **subscribed** (Boolean) Whether the authenticated user is subscribed to the issue or not.
76+
- **task_completion_status** (List of Object) The task completion status. It's always a one element list. (see [below for nested schema](#nestedatt--task_completion_status))
77+
- **time_estimate** (Number) The time estimate of the issue.
78+
- **title** (String) The title of the issue.
79+
- **total_time_spent** (Number) The total time spent of the issue.
80+
- **updated_at** (String) When the issue was updated. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
81+
- **upvotes** (Number) The number of upvotes the issue has received.
82+
- **user_notes_count** (Number) The number of user notes on the issue.
83+
- **web_url** (String) The web URL of the issue.
84+
- **weight** (Number) The weight of the issue. Valid values are greater than or equal to 0.
85+
86+
<a id="nestedatt--task_completion_status"></a>
87+
### Nested Schema for `task_completion_status`
88+
89+
Read-Only:
90+
91+
- **completed_count** (Number)
92+
- **count** (Number)
93+
94+

docs/data-sources/project_issues.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gitlab_project_issues Data Source - terraform-provider-gitlab"
4+
subcategory: ""
5+
description: |-
6+
The gitlab_project_issues data source allows to retrieve details about issues in a project.
7+
Upstream API: GitLab API docs https://docs.gitlab.com/ee/api/issues.html
8+
---
9+
10+
# gitlab_project_issues (Data Source)
11+
12+
The `gitlab_project_issues` data source allows to retrieve details about issues in a project.
13+
14+
**Upstream API:** [GitLab API docs](https://docs.gitlab.com/ee/api/issues.html)
15+
16+
## Example Usage
17+
18+
```terraform
19+
data "gitlab_project" "foo" {
20+
id = "foo/bar/baz"
21+
}
22+
23+
data "gitlab_project_issues" "all_with_foo" {
24+
project = data.gitlab_project.foo.id
25+
search = "foo"
26+
}
27+
```
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Required
33+
34+
- **project** (String) The name or id of the project.
35+
36+
### Optional
37+
38+
- **assignee_id** (Number) Return issues assigned to the given user id. Mutually exclusive with assignee_username. None returns unassigned issues. Any returns issues with an assignee.
39+
- **assignee_username** (String) Return issues assigned to the given username. Similar to assignee_id and mutually exclusive with assignee_id. In GitLab CE, the assignee_username array should only contain a single value. Otherwise, an invalid parameter error is returned.
40+
- **author_id** (Number) Return issues created by the given user id. Combine with scope=all or scope=assigned_to_me.
41+
- **confidential** (Boolean) Filter confidential or public issues.
42+
- **created_after** (String) Return issues created on or after the given time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)
43+
- **created_before** (String) Return issues created on or before the given time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)
44+
- **due_date** (String) Return issues that have no due date, are overdue, or whose due date is this week, this month, or between two weeks ago and next month. Accepts: 0 (no due date), any, today, tomorrow, overdue, week, month, next_month_and_previous_two_weeks.
45+
- **id** (String) The ID of this resource.
46+
- **iids** (List of Number) Return only the issues having the given iid
47+
- **issue_type** (String) Filter to a given type of issue. Valid values are [issue incident test_case]. (Introduced in GitLab 13.12)
48+
- **labels** (List of String) Return issues with labels. Issues must have all labels to be returned. None lists all issues with no labels. Any lists all issues with at least one label. No+Label (Deprecated) lists all issues with no labels. Predefined names are case-insensitive.
49+
- **milestone** (String) The milestone title. None lists all issues with no milestone. Any lists all issues that have an assigned milestone.
50+
- **my_reaction_emoji** (String) Return issues reacted by the authenticated user by the given emoji. None returns issues not given a reaction. Any returns issues given at least one reaction.
51+
- **not_assignee_id** (List of Number) Return issues that do not match the assignee id.
52+
- **not_author_id** (List of Number) Return issues that do not match the author id.
53+
- **not_labels** (List of String) Return issues that do not match the labels.
54+
- **not_milestone** (List of String) Return issues that do not match the milestone.
55+
- **not_my_reaction_emoji** (List of String) Return issues not reacted by the authenticated user by the given emoji.
56+
- **order_by** (String) Return issues ordered by. Valid values are `created_at`, `updated_at`, `priority`, `due_date`, `relative_position`, `label_priority`, `milestone_due`, `popularity`, `weight`. Default is created_at
57+
- **scope** (String) Return issues for the given scope. Valid values are `created_by_me`, `assigned_to_me`, `all`. Defaults to all.
58+
- **search** (String) Search project issues against their title and description
59+
- **sort** (String) Return issues sorted in asc or desc order. Default is desc
60+
- **updated_after** (String) Return issues updated on or after the given time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)
61+
- **updated_before** (String) Return issues updated on or before the given time. Expected in ISO 8601 format (2019-03-15T08:00:00Z)
62+
- **weight** (Number) Return issues with the specified weight. None returns issues with no weight assigned. Any returns issues with a weight assigned.
63+
- **with_labels_details** (Boolean) If true, the response returns more details for each label in labels field: :name, :color, :description, :description_html, :text_color. Default is false. description_html was introduced in GitLab 12.7
64+
65+
### Read-Only
66+
67+
- **issues** (List of Object) The list of issues returned by the search. (see [below for nested schema](#nestedatt--issues))
68+
69+
<a id="nestedatt--issues"></a>
70+
### Nested Schema for `issues`
71+
72+
Read-Only:
73+
74+
- **assignee_ids** (Set of Number)
75+
- **author_id** (Number)
76+
- **closed_at** (String)
77+
- **closed_by_user_id** (Number)
78+
- **confidential** (Boolean)
79+
- **created_at** (String)
80+
- **description** (String)
81+
- **discussion_locked** (Boolean)
82+
- **discussion_to_resolve** (String)
83+
- **downvotes** (Number)
84+
- **due_date** (String)
85+
- **epic_id** (Number)
86+
- **epic_issue_id** (Number)
87+
- **external_id** (String)
88+
- **human_time_estimate** (String)
89+
- **human_total_time_spent** (String)
90+
- **iid** (Number)
91+
- **issue_id** (Number)
92+
- **issue_link_id** (Number)
93+
- **issue_type** (String)
94+
- **labels** (Set of String)
95+
- **links** (Map of String)
96+
- **merge_request_to_resolve_discussions_of** (Number)
97+
- **merge_requests_count** (Number)
98+
- **milestone_id** (Number)
99+
- **moved_to_id** (Number)
100+
- **project** (String)
101+
- **references** (Map of String)
102+
- **state** (String)
103+
- **subscribed** (Boolean)
104+
- **task_completion_status** (List of Object) (see [below for nested schema](#nestedobjatt--issues--task_completion_status))
105+
- **time_estimate** (Number)
106+
- **title** (String)
107+
- **total_time_spent** (Number)
108+
- **updated_at** (String)
109+
- **upvotes** (Number)
110+
- **user_notes_count** (Number)
111+
- **web_url** (String)
112+
- **weight** (Number)
113+
114+
<a id="nestedobjatt--issues--task_completion_status"></a>
115+
### Nested Schema for `issues.task_completion_status`
116+
117+
Read-Only:
118+
119+
- **completed_count** (Number)
120+
- **count** (Number)
121+
122+

docs/resources/project_issue.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "gitlab_project_issue Resource - terraform-provider-gitlab"
4+
subcategory: ""
5+
description: |-
6+
The gitlab_project_issue resource allows to manage the lifecycle of an issue within a project.
7+
-> During a terraform destroy this resource will close the issue. Set the deleteondestroy flag to true to delete the issue instead of closing it.
8+
~> Experimental: while the base functionality of this resource works, it may be subject to minor change.
9+
Upstream API: GitLab API docs https://docs.gitlab.com/ee/api/issues.html
10+
---
11+
12+
# gitlab_project_issue (Resource)
13+
14+
The `gitlab_project_issue` resource allows to manage the lifecycle of an issue within a project.
15+
16+
-> During a terraform destroy this resource will close the issue. Set the delete_on_destroy flag to true to delete the issue instead of closing it.
17+
18+
~> **Experimental**: while the base functionality of this resource works, it may be subject to minor change.
19+
20+
**Upstream API:** [GitLab API docs](https://docs.gitlab.com/ee/api/issues.html)
21+
22+
## Example Usage
23+
24+
```terraform
25+
resource "gitlab_project" "foo" {
26+
name = "example project"
27+
description = "Lorem Ipsum"
28+
visibility_level = "public"
29+
}
30+
31+
resource "gitlab_project_issue" "welcome_issue" {
32+
project = gitlab_project.foo.id
33+
title = "Welcome!"
34+
description = <<EOT
35+
Welcome to the ${gitlab_project.foo.name} project!
36+
37+
EOT
38+
discussion_locked = true
39+
}
40+
41+
output "welcome_issue_web_url" {
42+
value = data.gitlab_project_issue.web_url
43+
}
44+
```
45+
46+
<!-- schema generated by tfplugindocs -->
47+
## Schema
48+
49+
### Required
50+
51+
- **project** (String) The name or ID of the project.
52+
- **title** (String) The title of the issue.
53+
54+
### Optional
55+
56+
- **assignee_ids** (Set of Number) The IDs of the users to assign the issue to.
57+
- **closed_at** (String) When the issue was closed. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
58+
- **closed_by_user_id** (Number) The ID of the user that closed the issue. Use `gitlab_user` data source to get more information about the user.
59+
- **confidential** (Boolean) Set an issue to be confidential.
60+
- **created_at** (String) When the issue was created. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z. Requires administrator or project/group owner rights.
61+
- **delete_on_destroy** (Boolean) Whether the issue is deleted instead of closed during destroy.
62+
- **description** (String) The description of an issue. Limited to 1,048,576 characters.
63+
- **discussion_locked** (Boolean) Whether the issue is locked for discussions or not.
64+
- **discussion_to_resolve** (String) The ID of a discussion to resolve. This fills out the issue with a default description and mark the discussion as resolved. Use in combination with merge_request_to_resolve_discussions_of.
65+
- **due_date** (String) The due date. Date time string in the format YYYY-MM-DD, for example 2016-03-11.
66+
**Note:** removing a due date is currently not supported, see https://github.com/xanzy/go-gitlab/issues/1384 for details.
67+
- **epic_issue_id** (Number) The ID of the epic issue.
68+
- **human_time_estimate** (String) The human-readable time estimate of the issue.
69+
- **human_total_time_spent** (String) The human-readable total time spent of the issue.
70+
- **id** (String) The ID of this resource.
71+
- **iid** (Number) The internal ID of the project's issue.
72+
- **issue_type** (String) The type of issue. Valid values are: `issue`, `incident`, `test_case`.
73+
- **labels** (Set of String) The labels of an issue.
74+
- **links** (Map of String) The links of the issue.
75+
- **merge_request_to_resolve_discussions_of** (Number) The IID of a merge request in which to resolve all issues. This fills out the issue with a default description and mark all discussions as resolved. When passing a description or title, these values take precedence over the default values.
76+
- **milestone_id** (Number) The global ID of a milestone to assign issue. To find the milestone_id associated with a milestone, view an issue with the milestone assigned and use the API to retrieve the issue's details.
77+
- **references** (Map of String) The references of the issue.
78+
- **state** (String) The state of the issue. Valid values are: `opened`, `closed`.
79+
- **task_completion_status** (Block List, Max: 1) The task completion status. It's always a one element list. (see [below for nested schema](#nestedblock--task_completion_status))
80+
- **time_estimate** (Number) The time estimate of the issue.
81+
- **total_time_spent** (Number) The total time spent of the issue.
82+
- **updated_at** (String) When the issue was updated. Date time string, ISO 8601 formatted, for example 2016-03-11T03:45:40Z.
83+
- **weight** (Number) The weight of the issue. Valid values are greater than or equal to 0.
84+
85+
### Read-Only
86+
87+
- **author_id** (Number) The ID of the author of the issue. Use `gitlab_user` data source to get more information about the user.
88+
- **downvotes** (Number) The number of downvotes the issue has received.
89+
- **epic_id** (Number) ID of the epic to add the issue to. Valid values are greater than or equal to 0.
90+
- **external_id** (String) The external ID of the issue.
91+
- **issue_id** (Number) The instance-wide ID of the issue.
92+
- **issue_link_id** (Number) The ID of the issue link.
93+
- **merge_requests_count** (Number) The number of merge requests associated with the issue.
94+
- **moved_to_id** (Number) The ID of the issue that was moved to.
95+
- **subscribed** (Boolean) Whether the authenticated user is subscribed to the issue or not.
96+
- **upvotes** (Number) The number of upvotes the issue has received.
97+
- **user_notes_count** (Number) The number of user notes on the issue.
98+
- **web_url** (String) The web URL of the issue.
99+
100+
<a id="nestedblock--task_completion_status"></a>
101+
### Nested Schema for `task_completion_status`
102+
103+
Optional:
104+
105+
- **completed_count** (Number) The number of tasks that are completed.
106+
- **count** (Number) The number of tasks.
107+
108+
## Import
109+
110+
Import is supported using the following syntax:
111+
112+
```shell
113+
# You can import this resource with an id made up of `{project-id}:{issue-id}`, e.g.
114+
terraform import gitlab_project_issue.welcome_issue 42:1
115+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
data "gitlab_project" "foo" {
2+
id = "foo/bar/baz"
3+
}
4+
5+
data "gitlab_project_issue" "welcome_issue" {
6+
project = data.gitlab_project.foo.id
7+
iid = 1
8+
}
9+
10+
output "welcome_issue_web_url" {
11+
value = data.gitlab_project_issue.web_url
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
data "gitlab_project" "foo" {
2+
id = "foo/bar/baz"
3+
}
4+
5+
data "gitlab_project_issues" "all_with_foo" {
6+
project = data.gitlab_project.foo.id
7+
search = "foo"
8+
}
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-id}`, e.g.
2+
terraform import gitlab_project_issue.welcome_issue 42:1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "gitlab_project" "foo" {
2+
name = "example project"
3+
description = "Lorem Ipsum"
4+
visibility_level = "public"
5+
}
6+
7+
resource "gitlab_project_issue" "welcome_issue" {
8+
project = gitlab_project.foo.id
9+
title = "Welcome!"
10+
description = <<EOT
11+
Welcome to the ${gitlab_project.foo.name} project!
12+
13+
EOT
14+
discussion_locked = true
15+
}
16+
17+
output "welcome_issue_web_url" {
18+
value = data.gitlab_project_issue.web_url
19+
}

0 commit comments

Comments
 (0)