Skip to content

Commit

Permalink
Merge pull request #978 from imjaroiswebdev/CSGINS-1665-IW-is-enabled…
Browse files Browse the repository at this point in the history
…-field

[CSGINS-1665] Add support  for `is_enabled` field to `pagerduty_incidenet_workflow`
  • Loading branch information
imjaroiswebdev authored Feb 6, 2025
2 parents 383457c + d5e5ba5 commit 415e483
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
github.com/heimweh/go-pagerduty v0.0.0-20250113182705-ce1f94dc30af
github.com/heimweh/go-pagerduty v0.0.0-20250206202923-12b6de611ec0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/heimweh/go-pagerduty v0.0.0-20250113182705-ce1f94dc30af h1:41UndNNQiIhLMxleHdJNTxmpHzT06twPUNRaqfJaSpU=
github.com/heimweh/go-pagerduty v0.0.0-20250113182705-ce1f94dc30af/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/heimweh/go-pagerduty v0.0.0-20250206202923-12b6de611ec0 h1:ixfkJ7Vb93KR9NkmBWjs+tKZi/W3l+CfvYYeYtr4dPM=
github.com/heimweh/go-pagerduty v0.0.0-20250206202923-12b6de611ec0/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
16 changes: 16 additions & 0 deletions pagerduty/resource_pagerduty_incident_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func resourcePagerDutyIncidentWorkflow() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"is_enabled": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateDiagFunc: validateValueDiagFunc([]string{
"true",
"false",
}),
},
"step": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -477,6 +486,9 @@ func flattenIncidentWorkflow(
if iw.Team != nil {
d.Set("team", iw.Team.ID)
}
if iw.IsEnabled != nil {
d.Set("is_enabled", strconv.FormatBool(*iw.IsEnabled))
}

if includeSteps {
steps := flattenIncidentWorkflowSteps(iw, specifiedSteps, isImport)
Expand Down Expand Up @@ -618,6 +630,10 @@ func buildIncidentWorkflowStruct(d *schema.ResourceData) (
ID: team.(string),
}
}
if is_enabled, ok := d.GetOk("is_enabled"); ok {
b := is_enabled.(string) == "true"
iw.IsEnabled = &b
}

specifiedSteps := make([]*SpecifiedStep, 0)
if steps, ok := d.GetOk("step"); ok {
Expand Down
3 changes: 3 additions & 0 deletions pagerduty/resource_pagerduty_incident_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestAccPagerDutyIncidentWorkflow_Basic(t *testing.T) {
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow.test", "name", workflowName),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "description", "Managed by Terraform"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "is_enabled", "true"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.#", "2"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.0.input.#", "1"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.0.input.0.generated", "false"),
Expand All @@ -81,6 +82,7 @@ func TestAccPagerDutyIncidentWorkflow_Basic(t *testing.T) {
"pagerduty_incident_workflow.test", "name", workflowName),
resource.TestCheckResourceAttr(
"pagerduty_incident_workflow.test", "description", "some description"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "is_enabled", "false"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.#", "2"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.0.input.#", "1"),
resource.TestCheckResourceAttr("pagerduty_incident_workflow.test", "step.0.input.0.generated", "false"),
Expand Down Expand Up @@ -327,6 +329,7 @@ func testAccCheckPagerDutyIncidentWorkflowConfigUpdate(name string) string {
resource "pagerduty_incident_workflow" "test" {
name = "%s"
description = "some description"
is_enabled = false
step {
name = "Example Step"
action = "pagerduty.com:incident-workflows:send-status-update:1"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ github.com/hashicorp/terraform-svchost
# github.com/hashicorp/yamux v0.1.1
## explicit; go 1.15
github.com/hashicorp/yamux
# github.com/heimweh/go-pagerduty v0.0.0-20250113182705-ce1f94dc30af
# github.com/heimweh/go-pagerduty v0.0.0-20250206202923-12b6de611ec0
## explicit; go 1.17
github.com/heimweh/go-pagerduty/pagerduty
github.com/heimweh/go-pagerduty/persistentconfig
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/incident_workflow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The following arguments are supported:

* `name` - (Required) The name of the workflow.
* `description` - (Optional) The description of the workflow.
* `is_enabled` - (Optional) Indicates whether the Incident Workflow is enabled or not. Disabled workflows will not be triggered, and will not count toward the account's enabled workflow limit.
* `team` - (Optional) A team ID. If specified then workflow edit permissions will be scoped to members of this team.
* `step` - (Optional) The steps in the workflow.

Expand Down

0 comments on commit 415e483

Please sign in to comment.