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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA-1837 Add only_invocable_on_unresolved_incidents to Automation Action's schema. #945

Merged
merged 3 commits into from
Nov 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pagerduty/data_source_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func dataSourcePagerDutyAutomationActionsAction() *schema.Resource {
Computed: true,
Optional: true,
},
"only_invocable_on_unresolved_incidents": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ resource "pagerduty_automation_actions_action" "test" {
process_automation_job_arguments = "-arg 1"
process_automation_node_filter = "tags: production"
}
only_invocable_on_unresolved_incidents = true
}

data "pagerduty_automation_actions_action" "foo" {
Expand Down
17 changes: 17 additions & 0 deletions pagerduty/resource_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func resourcePagerDutyAutomationActionsAction() *schema.Resource {
Computed: true,
Optional: true,
},
"only_invocable_on_unresolved_incidents": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -153,6 +158,14 @@ func buildAutomationActionsActionStruct(d *schema.ResourceData) (*pagerduty.Auto
automationActionsAction.ModifyTime = &val
}

if attr, ok := d.GetOk("only_invocable_on_unresolved_incidents"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetOk will return ok equal to false even when the value is explicitly set to false. Since the client defines this field as omitempty it would never get changed to false.
I'd change this whole if block to:

attr, _ :=  d.Get("only_invocable_on_unresolved_incidents").(bool)
automationActionsAction.OnlyInvocableOnUnresolvedIncidents = &attr

val := attr.(bool)
automationActionsAction.OnlyInvocableOnUnresolvedIncidents = &val
}

attr, _ := d.Get("only_invocable_on_unresolved_incidents").(bool)
automationActionsAction.OnlyInvocableOnUnresolvedIncidents = &attr

return &automationActionsAction, nil
}

Expand Down Expand Up @@ -298,6 +311,10 @@ func resourcePagerDutyAutomationActionsActionRead(d *schema.ResourceData, meta i
if automationActionsAction.ActionClassification != nil {
d.Set("action_classification", &automationActionsAction.ActionClassification)
}

if automationActionsAction.OnlyInvocableOnUnresolvedIncidents != nil {
d.Set("only_invocable_on_unresolved_incidents", *automationActionsAction.OnlyInvocableOnUnresolvedIncidents)
}
}
return nil
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"),
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "true"),
),
},
{
Expand Down Expand Up @@ -84,6 +85,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"),
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
),
},
},
Expand Down Expand Up @@ -127,6 +129,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) {
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
),
},
{
Expand All @@ -152,6 +155,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) {
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
),
},
},
Expand Down Expand Up @@ -215,6 +219,7 @@ resource "pagerduty_automation_actions_action" "foo" {
process_automation_job_arguments = "-arg 1"
process_automation_node_filter = "tags: production"
}
only_invocable_on_unresolved_incidents = "true"
}
`, actionName, actionName)
}
Expand All @@ -238,7 +243,8 @@ resource "pagerduty_automation_actions_action" "foo" {
runner_id = pagerduty_automation_actions_runner.foo_runner.id
action_data_reference {
process_automation_job_id = "updated_pa_job_id_123"
}
}
only_invocable_on_unresolved_incidents = "false"
}
`, previousActionName, actionName, actionDescription, actionClassification)
}
Expand Down

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

7 changes: 4 additions & 3 deletions website/docs/d/automation_actions_action.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ The following attributes are exported:
* `id` - The ID of the action.
* `name` - The name of the action.
* `type` - The type of object. The value returned will be `action`.
* `action_type` - The type of the action. The only allowed values are `process_automation` and `script`.
* `action_type` - The type of the action. The only allowed values are `process_automation` and `script`.
* `creation_time` - The time action was created. Represented as an ISO 8601 timestamp.
* `action_data_reference` - Action Data block. Action Data is documented below.
* `description` - (Optional) The description of the action.
* `runner_id` - (Optional) The Process Automation Actions runner to associate the action with.
* `runner_id` - (Optional) The Process Automation Actions runner to associate the action with.
* `runner_type` - (Optional) The type of the runner associated with the action.
* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`.
* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`.
* `modify_time` - (Optional) The last time action has been modified. Represented as an ISO 8601 timestamp.
* `only_invocable_on_unresolved_incidents` - (Optional) Whether or not the action can be invoked on unresolved incidents.

Action Data (`action_data_reference`) supports the following:

Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/automation_actions_action.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The following arguments are supported:
* `action_type` - (Required) The type of the action. The only allowed values are `process_automation` and `script`. Cannot be changed once set.
* `action_data_reference` - (Required) Action Data block. Action Data is documented below.
* `runner_id` - (Optional) The Process Automation Actions runner to associate the action with. Cannot be changed for the `process_automation` action type once set.
* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`.
* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`.

Action Data (`action_data_reference`) supports the following:

Expand All @@ -52,6 +52,7 @@ Action Data (`action_data_reference`) supports the following:
* `process_automation_node_filter` - (Optional) The expression that filters on which nodes a Process Automation Job executes [Learn more](https://docs.rundeck.com/docs/manual/05-nodes.html#node-filtering).
* `script` - (Required for `script` action_type) Body of the script to be executed on the Runner. Max length is 16777215 characters.
* `invocation_command` - (Optional) The command to execute the script with.
* `only_invocable_on_unresolved_incidents` - (Optional) Whether or not the action can be invoked on unresolved incidents.

## Attributes Reference

Expand Down
Loading