Skip to content

Commit

Permalink
SP-9630 add runbookLink to alerts (#120)
Browse files Browse the repository at this point in the history
* add runbookLink

* runbookLink -> runbook_link

* update documentation
  • Loading branch information
rachel-molnar-swi authored Feb 13, 2025
1 parent 458fbcf commit 5b7f009
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ resource "swo_alert" "https_response_time" {

- `description` (String) Alert description.
- `enabled` (Boolean) True if the Alert should be evaluated. Default is `true`.
- `runbook_link` (String) A runbook is documentation of what steps to follow when something goes wrong.
- `trigger_reset_actions` (Boolean) True if a notification should be sent when an active alert returns to normal. Default is false. Default is `false`.

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/uri.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ Required:

- `location_options` (Attributes Set) The Website availability monitoring location options. (see [below for nested schema](#nestedatt--test_definitions--location_options))
- `test_from_location` (String) The location type to test from. Valid values are [`REGION`|`COUNTRY`|`CITY`].
- `test_interval_in_seconds` (Number) The interval to test in seconds.

Optional:

- `platform_options` (Attributes) The platform options for this Uri check. (see [below for nested schema](#nestedatt--test_definitions--platform_options))
- `test_interval_in_seconds` (Number) The interval to test in seconds. Default is `900`. Valid values are `60, 300, 600, 900, 1800, 3600, 7200, 14400`

<a id="nestedatt--test_definitions--location_options"></a>

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/website.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Required:
- `platform_options` (Attributes) The Website availability monitoring platform options. (see [below for nested schema](#nestedatt--monitoring--availability--platform_options))
- `protocols` (List of String) The Website availability monitoring protocols.
- `test_from_location` (String) The Website availability monitoring test from location. Valid values are [`REGION`|`COUNTRY`|`CITY`].
- `test_interval_in_seconds` (Number) The Website availability monitoring test interval in seconds. Valid values are `60, 300, 600, 900, 1800, 3600, 7200, 14400`
- `test_interval_in_seconds` (Number) The Website availability monitoring test interval in seconds. Valid values are 60, 300, 600, 900, 1800, 3600, 7200, 14400

Optional:

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/solarwinds/swo-client-go v0.0.11
github.com/solarwinds/swo-client-go v0.0.12
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/solarwinds/swo-client-go v0.0.11 h1:0vmqJ3HY2H55rRLKdwE6nsEMbbAVhyy7lEAXyh2a4F4=
github.com/solarwinds/swo-client-go v0.0.11/go.mod h1:qwmAfdCcUbpX1euHV2DziKwgGVnGw8obvOb8/JCStqM=
github.com/solarwinds/swo-client-go v0.0.12 h1:WuNQqemtAJ66lf5pm0hV+JHsl5K3wsJ39kQHZhzfn0Q=
github.com/solarwinds/swo-client-go v0.0.12/go.mod h1:qwmAfdCcUbpX1euHV2DziKwgGVnGw8obvOb8/JCStqM=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
Expand Down
1 change: 1 addition & 0 deletions internal/provider/alert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (model *alertResourceModel) toAlertDefinitionInput() swoClient.AlertDefinit
Actions: model.toAlertActionInput(),
TriggerResetActions: model.TriggerResetActions.ValueBoolPointer(),
Condition: conditions,
RunbookLink: model.RunbookLink.ValueStringPointer(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions internal/provider/alert_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestAccAlertResource(t *testing.T) {
resource.TestCheckResourceAttr("swo_alert.test", "conditions.0.exclude_tags.0.values.0", "test-service"),
resource.TestCheckResourceAttr("swo_alert.test", "notifications.0", "123"),
resource.TestCheckResourceAttr("swo_alert.test", "notifications.1", "456"),
resource.TestCheckResourceAttr("swo_alert.test", "runbook_link", "https://www.runbooklink.com"),
),
},
// ImportState testing
Expand Down Expand Up @@ -96,6 +97,7 @@ resource "swo_alert" "test" {
},
]
notifications = ["123", "456"]
runbook_link = "https://www.runbooklink.com"
}
`, name)
}
5 changes: 5 additions & 0 deletions internal/provider/alert_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type alertResourceModel struct {
Conditions []alertConditionModel `tfsdk:"conditions"`
Notifications []string `tfsdk:"notifications"`
TriggerResetActions types.Bool `tfsdk:"trigger_reset_actions"`
RunbookLink types.String `tfsdk:"runbook_link"`
}

type alertConditionModel struct {
Expand Down Expand Up @@ -159,6 +160,10 @@ func (r *alertResource) Schema(ctx context.Context, req resource.SchemaRequest,
Required: true,
ElementType: types.StringType,
},
"runbook_link": schema.StringAttribute{
Description: "A runbook is documentation of what steps to follow when something goes wrong.",
Optional: true,
},
},
}
}

0 comments on commit 5b7f009

Please sign in to comment.