Skip to content

Commit e04e14e

Browse files
authored
Merge pull request #1 from bkondakor/claude/add-notification-config-vCk1v
Add notification rule, project/team scoping, and publisher data source
2 parents 3363a3c + 09c319f commit e04e14e

27 files changed

Lines changed: 2436 additions & 13 deletions

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ linters:
104104
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.Int32Attribute$"
105105
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.ListAttribute$"
106106
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.ListNestedAttribute$"
107+
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.SetAttribute$"
107108
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.NestedAttributeObject$"
108109
- "^github.com/hashicorp/terraform-plugin-framework/resource/schema\\.SingleNestedAttribute$"
109110
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.Schema$"
110111
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.StringAttribute$"
111112
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.BoolAttribute$"
112113
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.ListAttribute$"
113114
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.ListNestedAttribute$"
115+
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.SetAttribute$"
114116
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.NestedAttributeObject$"
115117
- "^github.com/hashicorp/terraform-plugin-framework/datasource/schema\\.SingleNestedAttribute$"
116118
- "^github.com/hashicorp/terraform-plugin-framework/providerserver\\.ServeOpts$"
@@ -130,6 +132,10 @@ linters:
130132
- "^github.com/DependencyTrack/client-go\\.SortOptions$"
131133
- "^github.com/DependencyTrack/client-go\\.Component$"
132134
- "^github.com/DependencyTrack/client-go\\.ManagedUser$"
135+
- "^github.com/DependencyTrack/client-go\\.NotificationRule$"
136+
- "^github.com/DependencyTrack/client-go\\.NotificationPublisher$"
137+
- "^github.com/DependencyTrack/client-go\\.GetAllRulesFilterOptions$"
138+
- "^github.com/DependencyTrack/client-go\\.CreateScheduledNotificationRuleRequest$"
133139
- "^terraform-provider-dependencytrack/internal/provider\\.[a-z][a-zA-Z]*Resource$"
134140
- "^terraform-provider-dependencytrack/internal/provider\\.[a-z][a-zA-Z]*DataSource$"
135141
- "^terraform-provider-dependencytrack/internal/provider\\.dependencyTrackProvider$"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_publisher Data Source - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Fetches a Notification Publisher by name.
7+
---
8+
9+
# dependencytrack_notification_publisher (Data Source)
10+
11+
Fetches a Notification Publisher by name.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Look up a built-in notification publisher by name
17+
data "dependencytrack_notification_publisher" "webhook" {
18+
name = "Outbound Webhook"
19+
}
20+
21+
# Other available publishers:
22+
# "Slack", "Microsoft Teams", "Mattermost", "Email",
23+
# "Console", "Cisco Webex", "Jira"
24+
```
25+
26+
<!-- schema generated by tfplugindocs -->
27+
## Schema
28+
29+
### Required
30+
31+
- `name` (String) Name of the Notification Publisher to look up. Built-in publishers include: Slack, Microsoft Teams, Mattermost, Email, Console, Outbound Webhook, Cisco Webex, Jira.
32+
33+
### Read-Only
34+
35+
- `default_publisher` (Boolean) Whether this is a default built-in publisher.
36+
- `description` (String) Description of the Notification Publisher.
37+
- `id` (String) UUID of the Notification Publisher.
38+
- `publisher_class` (String) Fully-qualified class name of the publisher implementation.

docs/data-sources/project.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@
33
page_title: "dependencytrack_project Data Source - dependencytrack"
44
subcategory: ""
55
description: |-
6-
Fetch an existing Project by name and version. Requires the project to have a version defined on DependencyTrack.
6+
Fetch an existing Project by name and version, or by name with is_latest set to true.
77
---
88

99
# dependencytrack_project (Data Source)
1010

11-
Fetch an existing Project by name and version. Requires the project to have a version defined on DependencyTrack.
11+
Fetch an existing Project by name and version, or by name with is_latest set to true.
1212

1313
## Example Usage
1414

1515
```terraform
16+
# Lookup by name and version
1617
data "dependencytrack_project" "example" {
1718
name = "Example"
1819
version = "v1"
1920
}
21+
22+
# Lookup the latest version (API 4.12+)
23+
data "dependencytrack_project" "latest" {
24+
name = "Example"
25+
is_latest = true
26+
}
2027
```
2128

2229
<!-- schema generated by tfplugindocs -->
@@ -25,12 +32,12 @@ data "dependencytrack_project" "example" {
2532
### Required
2633

2734
- `name` (String) Name of the project to find.
28-
- `version` (String) Version of the project to find.
2935

3036
### Optional
3137

32-
- `is_latest` (Boolean) Whether the project is the latest version. Available in API 4.12+.
38+
- `is_latest` (Boolean) Whether the project is the latest version. When true, version is optional and the latest project version will be returned. Available in API 4.12+.
3339
- `parent` (String) UUID of a parent project, if nested.
40+
- `version` (String) Version of the project to find. Optional when is_latest is true.
3441

3542
### Read-Only
3643

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Manages a Notification Rule.
7+
---
8+
9+
# dependencytrack_notification_rule (Resource)
10+
11+
Manages a Notification Rule.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Look up the Outbound Webhook publisher
17+
data "dependencytrack_notification_publisher" "webhook" {
18+
name = "Outbound Webhook"
19+
}
20+
21+
# Event-driven notification rule for new vulnerabilities
22+
resource "dependencytrack_notification_rule" "vuln_webhook" {
23+
name = "Vulnerability Webhook"
24+
scope = "PORTFOLIO"
25+
notification_level = "INFORMATIONAL"
26+
publisher_id = data.dependencytrack_notification_publisher.webhook.id
27+
notify_on = ["NEW_VULNERABILITY", "NEW_VULNERABLE_DEPENDENCY"]
28+
publisher_config = jsonencode({ destination = "https://example.com/webhook" })
29+
}
30+
31+
# Scheduled notification rule for daily vulnerability summary
32+
resource "dependencytrack_notification_rule" "daily_summary" {
33+
name = "Daily Vulnerability Summary"
34+
scope = "PORTFOLIO"
35+
notification_level = "INFORMATIONAL"
36+
trigger_type = "SCHEDULE"
37+
publisher_id = data.dependencytrack_notification_publisher.webhook.id
38+
notify_on = ["NEW_VULNERABILITIES_SUMMARY"]
39+
schedule_cron = "0 8 * * *"
40+
schedule_skip_unchanged = true
41+
publisher_config = jsonencode({ destination = "https://example.com/webhook" })
42+
}
43+
```
44+
45+
<!-- schema generated by tfplugindocs -->
46+
## Schema
47+
48+
### Required
49+
50+
- `name` (String) Name of the Notification Rule.
51+
- `publisher_id` (String) UUID for the Notification Publisher to use.
52+
- `scope` (String) Scope of the Notification Rule. Valid values are 'SYSTEM' and 'PORTFOLIO'.
53+
54+
### Optional
55+
56+
- `enabled` (Boolean) Whether the Notification Rule is enabled. Defaults to `true`.
57+
- `log_successful_publish` (Boolean) Whether to log successful notification publishes. Defaults to `false`.
58+
- `message` (String) Custom message for the notification. Maximum 1024 characters.
59+
- `notification_level` (String) Notification level threshold. Valid values are 'INFORMATIONAL', 'WARNING', 'ERROR'.
60+
- `notify_children` (Boolean) Whether to also notify for child projects. Defaults to `true`.
61+
- `notify_on` (Set of String) Set of notification group names to notify on. For PORTFOLIO scope: NEW_VULNERABILITY, NEW_VULNERABLE_DEPENDENCY, PROJECT_AUDIT_CHANGE, BOM_CONSUMED, BOM_PROCESSED, BOM_PROCESSING_FAILED, BOM_VALIDATION_FAILED, VEX_CONSUMED, VEX_PROCESSED, POLICY_VIOLATION, PROJECT_CREATED, USER_CREATED, USER_DELETED. For PORTFOLIO scheduled: NEW_VULNERABILITIES_SUMMARY, NEW_POLICY_VIOLATIONS_SUMMARY. For SYSTEM scope: CONFIGURATION, DATASOURCE_MIRRORING, REPOSITORY, INTEGRATION, INDEXING_SERVICE, FILE_SYSTEM, ANALYZER.
62+
- `publisher_config` (String) Publisher-specific configuration (e.g. webhook URL, email address). Typically JSON.
63+
- `schedule_cron` (String) Cron expression for scheduled notifications. Only applicable when trigger_type is 'SCHEDULE'.
64+
- `schedule_skip_unchanged` (Boolean) Whether to skip sending scheduled notifications when there are no changes. Only applicable when trigger_type is 'SCHEDULE'. Defaults to `false`.
65+
- `trigger_type` (String) Trigger type for the Notification Rule. Valid values are 'EVENT' and 'SCHEDULE'. Defaults to 'EVENT'.
66+
67+
### Read-Only
68+
69+
- `id` (String) UUID for the Notification Rule as generated by DependencyTrack.
70+
71+
## Import
72+
73+
Import is supported using the following syntax:
74+
75+
```shell
76+
terraform import dependencytrack_notification_rule.example <notification-rule-uuid>
77+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 an association of a Notification Rule to a Project. Only applicable for PORTFOLIO-scoped rules.
7+
---
8+
9+
# dependencytrack_notification_rule_project (Resource)
10+
11+
Manages an association of a Notification Rule to a Project. Only applicable for PORTFOLIO-scoped rules.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Scope a notification rule to a specific project
17+
resource "dependencytrack_notification_rule_project" "example" {
18+
rule = dependencytrack_notification_rule.vuln_webhook.id
19+
project = dependencytrack_project.example.id
20+
}
21+
```
22+
23+
<!-- schema generated by tfplugindocs -->
24+
## Schema
25+
26+
### Required
27+
28+
- `project` (String) UUID of the Project to associate with the Notification Rule.
29+
- `rule` (String) UUID of the Notification Rule.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule_tag Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Manages an association of a Notification Rule to a Tag. Only applicable for PORTFOLIO-scoped rules. Requires API version >= 4.12.
7+
---
8+
9+
# dependencytrack_notification_rule_tag (Resource)
10+
11+
Manages an association of a Notification Rule to a Tag. Only applicable for PORTFOLIO-scoped rules. Requires API version >= 4.12.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Scope a notification rule to projects with a specific tag
17+
resource "dependencytrack_notification_rule_tag" "example" {
18+
rule = dependencytrack_notification_rule.vuln_webhook.id
19+
tag = dependencytrack_tag.example.name
20+
}
21+
```
22+
23+
<!-- schema generated by tfplugindocs -->
24+
## Schema
25+
26+
### Required
27+
28+
- `rule` (String) UUID of the Notification Rule.
29+
- `tag` (String) Name of the Tag to associate with the Notification Rule.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 an association of a Notification Rule to a Team. Only applicable for rules using the Email publisher.
7+
---
8+
9+
# dependencytrack_notification_rule_team (Resource)
10+
11+
Manages an association of a Notification Rule to a Team. Only applicable for rules using the Email publisher.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Associate a team with an email notification rule
17+
resource "dependencytrack_notification_rule_team" "example" {
18+
rule = dependencytrack_notification_rule.email_alerts.id
19+
team = dependencytrack_team.security.id
20+
}
21+
```
22+
23+
<!-- schema generated by tfplugindocs -->
24+
## Schema
25+
26+
### Required
27+
28+
- `rule` (String) UUID of the Notification Rule.
29+
- `team` (String) UUID of the Team to associate with the Notification Rule.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Look up a built-in notification publisher by name
2+
data "dependencytrack_notification_publisher" "webhook" {
3+
name = "Outbound Webhook"
4+
}
5+
6+
# Other available publishers:
7+
# "Slack", "Microsoft Teams", "Mattermost", "Email",
8+
# "Console", "Cisco Webex", "Jira"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Look up the Outbound Webhook publisher
2+
data "dependencytrack_notification_publisher" "webhook" {
3+
name = "Outbound Webhook"
4+
}
5+
6+
# Event-driven notification rule for new vulnerabilities
7+
resource "dependencytrack_notification_rule" "vuln_webhook" {
8+
name = "Vulnerability Webhook"
9+
scope = "PORTFOLIO"
10+
notification_level = "INFORMATIONAL"
11+
publisher_id = data.dependencytrack_notification_publisher.webhook.id
12+
notify_on = ["NEW_VULNERABILITY", "NEW_VULNERABLE_DEPENDENCY"]
13+
publisher_config = jsonencode({ destination = "https://example.com/webhook" })
14+
}
15+
16+
# Scheduled notification rule for daily vulnerability summary
17+
resource "dependencytrack_notification_rule" "daily_summary" {
18+
name = "Daily Vulnerability Summary"
19+
scope = "PORTFOLIO"
20+
notification_level = "INFORMATIONAL"
21+
trigger_type = "SCHEDULE"
22+
publisher_id = data.dependencytrack_notification_publisher.webhook.id
23+
notify_on = ["NEW_VULNERABILITIES_SUMMARY"]
24+
schedule_cron = "0 8 * * *"
25+
schedule_skip_unchanged = true
26+
publisher_config = jsonencode({ destination = "https://example.com/webhook" })
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Scope a notification rule to a specific project
2+
resource "dependencytrack_notification_rule_project" "example" {
3+
rule = dependencytrack_notification_rule.vuln_webhook.id
4+
project = dependencytrack_project.example.id
5+
}

0 commit comments

Comments
 (0)