Skip to content

Commit

Permalink
Merge branch 'test-node-delete-fix' into release-1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor committed Aug 8, 2024
2 parents 42f6938 + f140f1e commit c3bb53f
Show file tree
Hide file tree
Showing 26 changed files with 194 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [1.13, 1.14, 1.15]
os: [ubuntu-latest, macos-latest]
go: [1.14, 1.15, 1.16]
os: [ubuntu-latest, macos-13]
make_target: [test, vet]

steps:
Expand Down
4 changes: 2 additions & 2 deletions examples/wallarm_integration_email.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "wallarm_integration_email" "email_integration" {
}

event {
event_type = "vuln"
event_type = "vuln_low"
active = true
}
}
}
4 changes: 2 additions & 2 deletions examples/wallarm_integration_insightconnect.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "wallarm_integration_insightconnect" "insight_integration" {
}

event {
event_type = "vuln"
event_type = "vuln_low"
active = true
}
}
}
3 changes: 2 additions & 1 deletion examples/wallarm_integration_splunk.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ resource "wallarm_integration_splunk" "splunk_integration" {
}

event {
event_type = "vuln"
event_type = "vuln_low"
active = true
}
}

4 changes: 2 additions & 2 deletions examples/wallarm_integration_sumologic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "wallarm_integration_sumologic" "sumologic_integration" {
}

event {
event_type = "vuln"
event_type = "vuln_low"
active = false
}
}
}
3 changes: 2 additions & 1 deletion examples/wallarm_integration_webhook.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "wallarm_integration_webhook" "wh_integration" {
}

event {
event_type = "vuln"
event_type = "vuln_low"
active = true
}

Expand All @@ -29,3 +29,4 @@ resource "wallarm_integration_webhook" "wh_integration" {
}

}

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/terraform-plugin-sdk v1.16.0
github.com/pkg/errors v0.9.1
github.com/wallarm/wallarm-go v0.4.0
github.com/wallarm/wallarm-go v0.5.0
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/tools v0.1.5 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/wallarm/wallarm-go v0.4.0 h1:EvGBeOPEDC4jWN2J+GWegvY1qwskosjHV9x6GgIoNSY=
github.com/wallarm/wallarm-go v0.4.0/go.mod h1:KQxO+EBaGpIgOqBoByKW4KNMEJFgkxR64FSiA4U/52I=
github.com/wallarm/wallarm-go v0.5.0 h1:v45VjHfummfLZ7K8hmmi/QFt7fmrT5IrgxxyEDUX7r8=
github.com/wallarm/wallarm-go v0.5.0/go.mod h1:KQxO+EBaGpIgOqBoByKW4KNMEJFgkxR64FSiA4U/52I=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
9 changes: 6 additions & 3 deletions wallarm/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ func resourceWallarmAppRead(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}

found := false
for _, app := range appResp.Body {
if app.ID == appID || app.Name == name {

if app.ID == appID {
found = true
d.Set("name", name)
d.Set("app_id", app.ID)
d.Set("client_id", clientID)
}
}
if !found {
d.SetId("")
}
return nil
}

Expand Down
23 changes: 15 additions & 8 deletions wallarm/resource_integration_email.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallarm

import (
"fmt"
"strings"

wallarm "github.com/wallarm/wallarm-go"

Expand Down Expand Up @@ -131,7 +132,12 @@ func resourceWallarmEmailRead(d *schema.ResourceData, m interface{}) error {
clientID := retrieveClientID(d, client)
email, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

d.Set("integration_id", email.ID)
Expand All @@ -157,7 +163,12 @@ func resourceWallarmEmailUpdate(d *schema.ResourceData, m interface{}) error {

email, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

var updateRes *wallarm.IntegrationCreateResp
Expand Down Expand Up @@ -198,12 +209,8 @@ func resourceWallarmEmailUpdate(d *schema.ResourceData, m interface{}) error {

func resourceWallarmEmailDelete(d *schema.ResourceData, m interface{}) error {
client := m.(wallarm.API)
clientID := retrieveClientID(d, client)
email, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
}
if err := client.IntegrationDelete(email.ID); err != nil {
integrationID := d.Get("integration_id").(int)
if err := client.IntegrationDelete(integrationID); err != nil {
return err
}
return nil
Expand Down
23 changes: 15 additions & 8 deletions wallarm/resource_integration_insightconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallarm

import (
"fmt"
"strings"

wallarm "github.com/wallarm/wallarm-go"

Expand Down Expand Up @@ -141,7 +142,12 @@ func resourceWallarmInsightConnectRead(d *schema.ResourceData, m interface{}) er
clientID := retrieveClientID(d, client)
insight, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

d.Set("integration_id", insight.ID)
Expand All @@ -168,7 +174,12 @@ func resourceWallarmInsightConnectUpdate(d *schema.ResourceData, m interface{})

insight, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

insightBody := wallarm.IntegrationWithAPICreate{
Expand Down Expand Up @@ -198,12 +209,8 @@ func resourceWallarmInsightConnectUpdate(d *schema.ResourceData, m interface{})

func resourceWallarmInsightConnectDelete(d *schema.ResourceData, m interface{}) error {
client := m.(wallarm.API)
clientID := retrieveClientID(d, client)
insight, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
}
if err := client.IntegrationDelete(insight.ID); err != nil {
integrationID := d.Get("integration_id").(int)
if err := client.IntegrationDelete(integrationID); err != nil {
return err
}

Expand Down
24 changes: 16 additions & 8 deletions wallarm/resource_integration_opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallarm

import (
"fmt"
"strings"

wallarm "github.com/wallarm/wallarm-go"

Expand Down Expand Up @@ -108,6 +109,7 @@ func resourceWallarmOpsGenieCreate(d *schema.ResourceData, m interface{}) error
active := d.Get("active").(bool)
events, err := expandWallarmEventToIntEvents(d.Get("event").(interface{}), "opsgenie")
if err != nil {
d.SetId("")
return err
}

Expand Down Expand Up @@ -141,7 +143,12 @@ func resourceWallarmOpsGenieRead(d *schema.ResourceData, m interface{}) error {
clientID := retrieveClientID(d, client)
opsGenie, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

d.Set("integration_id", opsGenie.ID)
Expand All @@ -168,7 +175,12 @@ func resourceWallarmOpsGenieUpdate(d *schema.ResourceData, m interface{}) error

opsgenie, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

opsgenieBody := wallarm.IntegrationWithAPICreate{
Expand Down Expand Up @@ -197,12 +209,8 @@ func resourceWallarmOpsGenieUpdate(d *schema.ResourceData, m interface{}) error

func resourceWallarmOpsGenieDelete(d *schema.ResourceData, m interface{}) error {
client := m.(wallarm.API)
clientID := retrieveClientID(d, client)
opsGenie, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
}
if err := client.IntegrationDelete(opsGenie.ID); err != nil {
integrationID := d.Get("integration_id").(int)
if err := client.IntegrationDelete(integrationID); err != nil {
return err
}

Expand Down
24 changes: 16 additions & 8 deletions wallarm/resource_integration_pagerduty.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallarm

import (
"fmt"
"strings"

wallarm "github.com/wallarm/wallarm-go"

Expand Down Expand Up @@ -107,6 +108,7 @@ func resourceWallarmPagerDutyCreate(d *schema.ResourceData, m interface{}) error
active := d.Get("active").(bool)
events, err := expandWallarmEventToIntEvents(d.Get("event").(interface{}), "pager_duty")
if err != nil {
d.SetId("")
return err
}

Expand Down Expand Up @@ -137,7 +139,12 @@ func resourceWallarmPagerDutyRead(d *schema.ResourceData, m interface{}) error {
clientID := retrieveClientID(d, client)
pagerduty, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

d.Set("integration_id", pagerduty.ID)
Expand All @@ -163,7 +170,12 @@ func resourceWallarmPagerDutyUpdate(d *schema.ResourceData, m interface{}) error

pagerDuty, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

pagerBody := wallarm.IntegrationCreate{
Expand All @@ -189,12 +201,8 @@ func resourceWallarmPagerDutyUpdate(d *schema.ResourceData, m interface{}) error

func resourceWallarmPagerDutyDelete(d *schema.ResourceData, m interface{}) error {
client := m.(wallarm.API)
clientID := retrieveClientID(d, client)
pagerduty, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
}
if err := client.IntegrationDelete(pagerduty.ID); err != nil {
integrationID := d.Get("integration_id").(int)
if err := client.IntegrationDelete(integrationID); err != nil {
return err
}

Expand Down
24 changes: 16 additions & 8 deletions wallarm/resource_integration_slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallarm

import (
"fmt"
"strings"

wallarm "github.com/wallarm/wallarm-go"

Expand Down Expand Up @@ -101,6 +102,7 @@ func resourceWallarmSlackCreate(d *schema.ResourceData, m interface{}) error {
active := d.Get("active").(bool)
events, err := expandWallarmEventToIntEvents(d.Get("event").(interface{}), "slack")
if err != nil {
d.SetId("")
return err
}

Expand Down Expand Up @@ -131,7 +133,12 @@ func resourceWallarmSlackRead(d *schema.ResourceData, m interface{}) error {
clientID := retrieveClientID(d, client)
slack, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}
d.Set("integration_id", slack.ID)
d.Set("is_active", slack.Active)
Expand All @@ -156,7 +163,12 @@ func resourceWallarmSlackUpdate(d *schema.ResourceData, m interface{}) error {

slack, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
if strings.HasPrefix(err.Error(), "Not found.") {
d.SetId("")
return nil
} else {
return err
}
}

slackBody := wallarm.IntegrationCreate{
Expand All @@ -182,12 +194,8 @@ func resourceWallarmSlackUpdate(d *schema.ResourceData, m interface{}) error {

func resourceWallarmSlackDelete(d *schema.ResourceData, m interface{}) error {
client := m.(wallarm.API)
clientID := retrieveClientID(d, client)
slack, err := client.IntegrationRead(clientID, d.Get("integration_id").(int))
if err != nil {
return err
}
if err := client.IntegrationDelete(slack.ID); err != nil {
integrationID := d.Get("integration_id").(int)
if err := client.IntegrationDelete(integrationID); err != nil {
return err
}

Expand Down
Loading

0 comments on commit c3bb53f

Please sign in to comment.