Skip to content

Commit 0673345

Browse files
Notifications assignments (#189)
* Add dependencytrack_notification_rule_project resource to mapping Notification Rules to Projects. * Add dependencytrack_notification_rule_team resource to specify the team to which to send email notifications. * Added dependencytrack_tag_notification_rules resource. * Self review. Updated test filter to disable 4.12+ tests for 4.11.7. Ammended incorrect tflogging of values.
1 parent 85bf459 commit 0673345

18 files changed

Lines changed: 1749 additions & 1 deletion

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
matrix:
142142
api:
143143
- version: "4.11.7"
144-
skip: "^(TestAccTagResource)|(TestAccProjectTagsRead)|(TestAccTagPoliciesResource)|(TestAccTagProjectsResource)|(TestAccProjectCollection)|(TestAccProjectIsLatest)|(TestAccProjectDataSourceIsLatest)|(TestAccNotificationRuleScheduleResource)$"
144+
skip: "^(TestAccTagResource)|(TestAccProjectTagsRead)|(TestAccTagPoliciesResource)|(TestAccTagProjectsResource)|(TestAccProjectCollection)|(TestAccProjectIsLatest)|(TestAccProjectDataSourceIsLatest)|(TestAccNotificationRuleScheduleResource)|(TestAccTagNotificationRulesResource)|(TestAccTagNotificationRulesResourceNotificationRulesUnordered)$"
145145
- version: "4.12.7"
146146
skip: "^(TestAccTagResource)|(TestAccProjectCollection)|(TestAccNotificationRuleScheduleResource)$"
147147
- version: "4.13.0"

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ linters:
135135
- "^github.com/DependencyTrack/client-go\\.LdapUser$"
136136
- "^github.com/DependencyTrack/client-go\\.UserPrincipal$"
137137
- "^github.com/DependencyTrack/client-go\\.NotificationPublisher$"
138+
- "^github.com/DependencyTrack/client-go\\.GetAllRulesFilterOptions$"
138139
- "^terraform-provider-dependencytrack/internal/provider\\.[a-z][a-zA-Z]*Resource$"
139140
- "^terraform-provider-dependencytrack/internal/provider\\.[a-z][a-zA-Z]*DataSource$"
140141
- "^terraform-provider-dependencytrack/internal/provider\\.dependencyTrackProvider$"
@@ -610,6 +611,9 @@ linters:
610611
- path: internal/provider/notification_rule_resource_test.go
611612
linters:
612613
- godox
614+
- path: internal/provider/tag_notification_rules_resource.go
615+
linters:
616+
- gocognit
613617

614618
formatters:
615619
enable:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule_project Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Manages a mapping for a Notification Rule to a Project
7+
---
8+
9+
# dependencytrack_notification_rule_project (Resource)
10+
11+
Manages a mapping for a Notification Rule to a Project
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "dependencytrack_notification_publisher" "example" {
17+
name = "Example Publisher"
18+
publisher_class = "org.dependencytrack.notification.publisher.ConsolePublisher"
19+
template_mime_type = "text/plain"
20+
}
21+
22+
resource "dependencytrack_notification_rule" "example" {
23+
name = "Example Event Rule"
24+
trigger_type = "EVENT"
25+
log_successful_publish = false
26+
notify_on = [
27+
"NEW_VULNERABILITY",
28+
"PROJECT_CREATED",
29+
"BOM_PROCESSED"
30+
]
31+
publisher_id = dependencytrack_notification_publisher.test.id
32+
}
33+
34+
resource "dependencytrack_project" "example" {
35+
name = "Example Project"
36+
}
37+
38+
resource "dependencytrack_notification_rule_project" "example" {
39+
rule = dependencytrack_notification_rule.example.id
40+
project = dependencytrack_project.example.id
41+
}
42+
```
43+
44+
<!-- schema generated by tfplugindocs -->
45+
## Schema
46+
47+
### Required
48+
49+
- `project` (String) UUID for the Project for which to generate Notifications.
50+
- `rule` (String) UUID for the Notification Rule to set for Project.
51+
52+
### Read-Only
53+
54+
- `id` (String) ID for the mapping. Has no meaning to DependencyTrack.
55+
56+
## Import
57+
58+
Import is supported using the following syntax:
59+
60+
```shell
61+
terraform import dependencytrack_notification_rule_project.example fdcff7ae-a0c0-4f54-9bb6-7bdb6c56c9fd/c82d6f01-a7a4-41d6-9b03-4f06497f575b
62+
```
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule_team Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Manages a mapping for a Notification Rule to a Team
7+
---
8+
9+
# dependencytrack_notification_rule_team (Resource)
10+
11+
Manages a mapping for a Notification Rule to a Team
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "dependencytrack_notification_publisher" "example" {
17+
name = "Example Publisher"
18+
publisher_class = "org.dependencytrack.notification.publisher.SendMailPublisher"
19+
template_mime_type = "text/plain"
20+
}
21+
22+
resource "dependencytrack_notification_rule" "example" {
23+
name = "Example Event Rule"
24+
trigger_type = "EVENT"
25+
log_successful_publish = false
26+
notify_on = [
27+
"NEW_VULNERABILITY",
28+
"PROJECT_CREATED",
29+
"BOM_PROCESSED"
30+
]
31+
publisher_id = dependencytrack_notification_publisher.test.id
32+
}
33+
34+
resource "dependencytrack_team" "example" {
35+
name = "Example Team"
36+
}
37+
38+
resource "dependencytrack_notification_rule_team" "example" {
39+
rule = dependencytrack_notification_rule.example.id
40+
team = dependencytrack_team.example.id
41+
}
42+
```
43+
44+
<!-- schema generated by tfplugindocs -->
45+
## Schema
46+
47+
### Required
48+
49+
- `rule` (String) UUID for the Notification Rule to set for Team. Must use an email publisher.
50+
- `team` (String) UUID for the Team for which to generate Notifications.
51+
52+
### Read-Only
53+
54+
- `id` (String) ID for the mapping. Has no meaning to DependencyTrack.
55+
56+
## Import
57+
58+
Import is supported using the following syntax:
59+
60+
```shell
61+
terraform import dependencytrack_notification_rule_team.example fdcff7ae-a0c0-4f54-9bb6-7bdb6c56c9fd/51e49752-6039-404b-bd4d-02e5d624a934
62+
```
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_tag_notification_rules Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Applies an existing tag to multiple notification rules. Requires API version >= 4.12.
7+
---
8+
9+
# dependencytrack_tag_notification_rules (Resource)
10+
11+
Applies an existing tag to multiple notification rules. Requires API version >= 4.12.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Requires DependencyTrack API v4.12+
17+
18+
resource "dependencytrack_project" "example" {
19+
name = "Example Project"
20+
tags = ["example_tag"]
21+
}
22+
23+
resource "dependencytrack_notification_publisher" "example" {
24+
name = "Example Publisher"
25+
publisher_class = "org.dependencytrack.notification.publisher.ConsolePublisher"
26+
template_mime_type = "text/plain"
27+
}
28+
29+
resource "dependencytrack_notification_rule" "example" {
30+
name = "Example Event Rule"
31+
trigger_type = "EVENT"
32+
log_successful_publish = false
33+
notify_on = [
34+
"NEW_VULNERABILITY",
35+
"PROJECT_CREATED",
36+
"BOM_PROCESSED"
37+
]
38+
publisher_id = dependencytrack_notification_publisher.test.id
39+
}
40+
41+
resource "dependencytrack_tag_notification_rules" "example" {
42+
tag = "example_tag"
43+
notification_rules = [
44+
dependencytrack_notification_rule.example.id,
45+
]
46+
depends_on = [dependencytrack_project.example]
47+
}
48+
```
49+
50+
<!-- schema generated by tfplugindocs -->
51+
## Schema
52+
53+
### Required
54+
55+
- `notification_rules` (List of String) Notification Rule UUIDs to which to apply tag.
56+
- `tag` (String) Name of the Tag.
57+
58+
### Read-Only
59+
60+
- `id` (String) Name of the Tag.
61+
62+
## Import
63+
64+
Import is supported using the following syntax:
65+
66+
```shell
67+
terraform import dependencytrack_tag_notification_rules.example example_tag
68+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import dependencytrack_notification_rule_project.example fdcff7ae-a0c0-4f54-9bb6-7bdb6c56c9fd/c82d6f01-a7a4-41d6-9b03-4f06497f575b
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "dependencytrack_notification_publisher" "example" {
2+
name = "Example Publisher"
3+
publisher_class = "org.dependencytrack.notification.publisher.ConsolePublisher"
4+
template_mime_type = "text/plain"
5+
}
6+
7+
resource "dependencytrack_notification_rule" "example" {
8+
name = "Example Event Rule"
9+
trigger_type = "EVENT"
10+
log_successful_publish = false
11+
notify_on = [
12+
"NEW_VULNERABILITY",
13+
"PROJECT_CREATED",
14+
"BOM_PROCESSED"
15+
]
16+
publisher_id = dependencytrack_notification_publisher.test.id
17+
}
18+
19+
resource "dependencytrack_project" "example" {
20+
name = "Example Project"
21+
}
22+
23+
resource "dependencytrack_notification_rule_project" "example" {
24+
rule = dependencytrack_notification_rule.example.id
25+
project = dependencytrack_project.example.id
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import dependencytrack_notification_rule_team.example fdcff7ae-a0c0-4f54-9bb6-7bdb6c56c9fd/51e49752-6039-404b-bd4d-02e5d624a934
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "dependencytrack_notification_publisher" "example" {
2+
name = "Example Publisher"
3+
publisher_class = "org.dependencytrack.notification.publisher.SendMailPublisher"
4+
template_mime_type = "text/plain"
5+
}
6+
7+
resource "dependencytrack_notification_rule" "example" {
8+
name = "Example Event Rule"
9+
trigger_type = "EVENT"
10+
log_successful_publish = false
11+
notify_on = [
12+
"NEW_VULNERABILITY",
13+
"PROJECT_CREATED",
14+
"BOM_PROCESSED"
15+
]
16+
publisher_id = dependencytrack_notification_publisher.test.id
17+
}
18+
19+
resource "dependencytrack_team" "example" {
20+
name = "Example Team"
21+
}
22+
23+
resource "dependencytrack_notification_rule_team" "example" {
24+
rule = dependencytrack_notification_rule.example.id
25+
team = dependencytrack_team.example.id
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import dependencytrack_tag_notification_rules.example example_tag

0 commit comments

Comments
 (0)