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

Add Slack v2 Connection Resource #381

Merged
merged 3 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ In order to run the full suite of Acceptance tests, run `make testacc`.
```sh
$ make testacc
```

*Additional Note:* In order for the tests on the Slack Connection resources to pass you will need valid Slack workspace and channel IDs from a [Slack workspace connected to your PagerDuty account](https://support.pagerduty.com/docs/slack-integration-guide#integration-walkthrough).
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go v0.71.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.7.0
github.com/heimweh/go-pagerduty v0.0.0-20210811005434-dc24e464325a
github.com/heimweh/go-pagerduty v0.0.0-20210831220234-54710c5e87d1
go.mongodb.org/mongo-driver v1.7.0 // indirect
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd // indirect
google.golang.org/api v0.35.0 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ github.com/heimweh/go-pagerduty v0.0.0-20210810155842-7de939d717c0 h1:F3c5KAaStF
github.com/heimweh/go-pagerduty v0.0.0-20210810155842-7de939d717c0/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210811005434-dc24e464325a h1:mPx+k0gk1FNkQgWutkSFO/IYcHFv8ueUdA/1hIDkO9E=
github.com/heimweh/go-pagerduty v0.0.0-20210811005434-dc24e464325a/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210817215245-9604e31ec66b h1:e4lTBCIrfI2Fq6MmQpEv7ejyearCTVw0m8WaW/G6a+Y=
github.com/heimweh/go-pagerduty v0.0.0-20210817215245-9604e31ec66b/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210825175603-80b7f8a9ddd7 h1:glR2g8bLfJzRJaSX13tK2aBd7QiZttr7xpfhxwXq1jY=
github.com/heimweh/go-pagerduty v0.0.0-20210825175603-80b7f8a9ddd7/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210825225232-caa0f6e992e6 h1:N39eXQVRlxiy0Of5NBJVhv0x3Jjsu3piCZY5v9Gy+vM=
github.com/heimweh/go-pagerduty v0.0.0-20210825225232-caa0f6e992e6/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210826184549-45940c9493fc h1:qK78KCqtm+9NDIWPffdGy9udPf7TX9iX+BRpocjhYpw=
github.com/heimweh/go-pagerduty v0.0.0-20210826184549-45940c9493fc/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/heimweh/go-pagerduty v0.0.0-20210831220234-54710c5e87d1 h1:yBAqdyzvIpGktzh8EnWqaXAtwhdgWqrP2Zk53MDH89Y=
github.com/heimweh/go-pagerduty v0.0.0-20210831220234-54710c5e87d1/go.mod h1:6+bccpjQ/PM8uQY9m8avM4MJea+3vo3ta9r8kGQ4XFY=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
64 changes: 64 additions & 0 deletions pagerduty/import_pagerduty_slack_connection_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package pagerduty

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccPagerDutySlackConnection_import(t *testing.T) {
username := fmt.Sprintf("tf-%s", acctest.RandString(5))
email := fmt.Sprintf("%s@foo.com", username)
escalationPolicy := fmt.Sprintf("tf-%s", acctest.RandString(5))
service := fmt.Sprintf("tf-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutySlackConnectionDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutySlackConnectionConfig(username, email, escalationPolicy, service, workspaceID, channelID),
},
{
Config: testAccCheckPagerDutySlackConnectionConfigUpdated(username, email, escalationPolicy, service, workspaceID, channelID),
},
{
ResourceName: "pagerduty_slack_connection.foo",
ImportStateIdFunc: testAccCheckPagerDutySlackConnectionID,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccPagerDutySlackConnectionTeam_import(t *testing.T) {
team := fmt.Sprintf("tf-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutySlackConnectionDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutySlackConnectionConfigTeam(team, workspaceID, channelID),
},
{
ResourceName: "pagerduty_slack_connection.foo",
ImportStateIdFunc: testAccCheckPagerDutySlackConnectionID,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckPagerDutySlackConnectionID(s *terraform.State) (string, error) {
scatts := s.RootModule().Resources["pagerduty_slack_connection.foo"].Primary.Attributes

return fmt.Sprintf("%v.%v", scatts["workspace_id"], s.RootModule().Resources["pagerduty_slack_connection.foo"].Primary.ID), nil
}
1 change: 1 addition & 0 deletions pagerduty/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func Provider() terraform.ResourceProvider {
"pagerduty_service_dependency": resourcePagerDutyServiceDependency(),
"pagerduty_response_play": resourcePagerDutyResponsePlay(),
"pagerduty_service_event_rule": resourcePagerDutyServiceEventRule(),
"pagerduty_slack_connection": resourcePagerDutySlackConnection(),
},
}

Expand Down
Loading