Skip to content

Commit

Permalink
patch - fixing nil pointer bug in alerts (#221)
Browse files Browse the repository at this point in the history
* patch - fixing nil pointer bug in alerts
  • Loading branch information
OrNovo authored Apr 8, 2024
1 parent 7f189f3 commit 328bedb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,9 @@ New Features:
## Release 1.13.1
Bug fixing:
#### resource/coralogix_dashboard
* adding schema upgrade v1 to v2 (for `annotations.source.metrics` field).
* adding schema upgrade v1 to v2 (for `annotations.source.metrics` field).

## Release 1.13.2
Bug fixing:
#### resource/coralogix_alert
* fixing [runtime error: invalid memory address or nil pointer dereference](https://github.com/coralogix/terraform-provider-coralogix/issues/212).
6 changes: 6 additions & 0 deletions coralogix/resource_coralogix_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -1547,10 +1547,16 @@ func extractCreateAlertRequest(d *schema.ResourceData) (*alerts.CreateAlertReque
incidentSettings := expandIncidentSettings(d.Get("incident_settings"))
notificationGroups, dgs := expandNotificationGroups(d.Get("notifications_group"))
diags = append(diags, dgs...)
if len(diags) != 0 {
return nil, diags
}
payloadFilters := expandPayloadFilters(d.Get("payload_filters"))
scheduling := expandActiveWhen(d.Get("scheduling"))
alertTypeParams, tracingAlert, dgs := expandAlertType(d)
diags = append(diags, dgs...)
if len(diags) != 0 {
return nil, diags
}

return &alerts.CreateAlertRequest{
Name: name,
Expand Down
6 changes: 4 additions & 2 deletions coralogix/resource_coralogix_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ func TestAccCoralogixResourceAlert_newValue(t *testing.T) {
keyToTrack: "EventType",
timeWindow: selectRandomlyFromSlice(alertValidNewValueTimeFrames),
}
alert.notifyOn = "Triggered_only"
checks := extractNewValueChecks(alert)

updatedAlert := newValueAlertTestParams{
alertCommonTestParams: *getRandomAlert(),
keyToTrack: "EventType",
timeWindow: selectRandomlyFromSlice(alertValidNewValueTimeFrames),
}
updatedAlert.notifyOn = "Triggered_only"
updatedAlertChecks := extractNewValueChecks(updatedAlert)

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -359,7 +361,7 @@ func TestAccCoralogixResourceAlert_flow(t *testing.T) {
severity: selectRandomlyFromSlice(alertValidSeverities),
activeWhen: randActiveWhen(),
notifyEveryMin: acctest.RandIntRange(1500 /*to avoid notify_every < condition.0.time_window*/, 3600),
notifyOn: selectRandomlyFromSlice(validNotifyOn),
notifyOn: "Triggered_only",
}
checks := extractFlowAlertChecks(alert)

Expand All @@ -371,7 +373,7 @@ func TestAccCoralogixResourceAlert_flow(t *testing.T) {
severity: selectRandomlyFromSlice(alertValidSeverities),
activeWhen: randActiveWhen(),
notifyEveryMin: acctest.RandIntRange(1500 /*to avoid notify_every < condition.0.time_window*/, 3600),
notifyOn: selectRandomlyFromSlice(validNotifyOn),
notifyOn: "Triggered_only",
}
updatedAlertChecks := extractFlowAlertChecks(updatedAlert)

Expand Down

0 comments on commit 328bedb

Please sign in to comment.