Skip to content

Commit

Permalink
Update all resource after provider logic change to support multi-regi…
Browse files Browse the repository at this point in the history
…on for slack resources
  • Loading branch information
jbfavre committed Oct 22, 2021
1 parent c806741 commit 1583820
Show file tree
Hide file tree
Showing 57 changed files with 154 additions and 162 deletions.
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func dataSourcePagerDutyBusinessService() *schema.Resource {
}

func dataSourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty business service")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func dataSourcePagerDutyEscalationPolicy() *schema.Resource {
}

func dataSourcePagerDutyEscalationPolicyRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty escalation policy")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_extension_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func dataSourcePagerDutyExtensionSchema() *schema.Resource {
}

func dataSourcePagerDutyExtensionSchemaRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty Extension Schema")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func dataSourcePagerDutyPriority() *schema.Resource {
}

func dataSourcePagerDutyPriorityRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty priority")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func dataSourcePagerDutyRuleset() *schema.Resource {
}

func dataSourcePagerDutyRulesetRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty ruleset")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func dataSourcePagerDutySchedule() *schema.Resource {
}

func dataSourcePagerDutyScheduleRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty schedule")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func dataSourcePagerDutyService() *schema.Resource {
}

func dataSourcePagerDutyServiceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty service")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_service_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func dataSourcePagerDutyServiceIntegration() *schema.Resource {
}

func dataSourcePagerDutyServiceIntegrationRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty service")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func dataSourcePagerDutyTag() *schema.Resource {
}

func dataSourcePagerDutyTagRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty tag")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func dataSourcePagerDutyTeam() *schema.Resource {
}

func dataSourcePagerDutyTeamRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty team")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func dataSourcePagerDutyUser() *schema.Resource {
}

func dataSourcePagerDutyUserRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty user")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_user_contact_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func dataSourcePagerDutyUserContactMethod() *schema.Resource {
}

func dataSourcePagerDutyUserContactMethodRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty user's contact method")

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func dataSourcePagerDutyVendor() *schema.Resource {
}

func dataSourcePagerDutyVendorRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty vendor")

Expand Down
8 changes: 4 additions & 4 deletions pagerduty/resource_pagerduty_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func buildAddonStruct(d *schema.ResourceData) *pagerduty.Addon {
}

func resourcePagerDutyAddonCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

addon := buildAddonStruct(d)

Expand All @@ -59,7 +59,7 @@ func resourcePagerDutyAddonCreate(d *schema.ResourceData, meta interface{}) erro
}

func resourcePagerDutyAddonRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty add-on %s", d.Id())

Expand All @@ -83,7 +83,7 @@ func resourcePagerDutyAddonRead(d *schema.ResourceData, meta interface{}) error
}

func resourcePagerDutyAddonUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

addon := buildAddonStruct(d)

Expand All @@ -97,7 +97,7 @@ func resourcePagerDutyAddonUpdate(d *schema.ResourceData, meta interface{}) erro
}

func resourcePagerDutyAddonDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Deleting PagerDuty add-on %s", d.Id())

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/resource_pagerduty_addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestAccPagerDutyAddon_Basic(t *testing.T) {
}

func testAccCheckPagerDutyAddonDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()
for _, r := range s.RootModule().Resources {
if r.Type != "pagerduty_addon" {
continue
Expand All @@ -106,7 +106,7 @@ func testAccCheckPagerDutyAddonExists(n string) resource.TestCheckFunc {
return fmt.Errorf("No add-on ID is set")
}

client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()

found, _, err := client.Addons.Get(rs.Primary.ID)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pagerduty/resource_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func buildBusinessServiceStruct(d *schema.ResourceData) (*pagerduty.BusinessServ
}

func resourcePagerDutyBusinessServiceCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError {

Expand All @@ -118,7 +118,7 @@ func resourcePagerDutyBusinessServiceCreate(d *schema.ResourceData, meta interfa
}

func resourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty business service %s", d.Id())

Expand Down Expand Up @@ -149,7 +149,7 @@ func resourcePagerDutyBusinessServiceRead(d *schema.ResourceData, meta interface
}

func resourcePagerDutyBusinessServiceUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

businessService, err := buildBusinessServiceStruct(d)
if err != nil {
Expand All @@ -168,7 +168,7 @@ func resourcePagerDutyBusinessServiceUpdate(d *schema.ResourceData, meta interfa
}

func resourcePagerDutyBusinessServiceDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Deleting PagerDuty business service %s", d.Id())

Expand Down
5 changes: 2 additions & 3 deletions pagerduty/resource_pagerduty_business_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/heimweh/go-pagerduty/pagerduty"
)

func init() {
Expand Down Expand Up @@ -132,7 +131,7 @@ func testAccCheckPagerDutyBusinessServiceExists(n string) resource.TestCheckFunc
return fmt.Errorf("No Business Service ID is set")
}

client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()

found, _, err := client.BusinessServices.Get(rs.Primary.ID)
if err != nil {
Expand All @@ -148,7 +147,7 @@ func testAccCheckPagerDutyBusinessServiceExists(n string) resource.TestCheckFunc
}

func testAccCheckPagerDutyBusinessServiceDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()
for _, r := range s.RootModule().Resources {
if r.Type != "pagerduty_business_service" {
continue
Expand Down
8 changes: 4 additions & 4 deletions pagerduty/resource_pagerduty_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func buildEscalationPolicyStruct(d *schema.ResourceData) *pagerduty.EscalationPo
}

func resourcePagerDutyEscalationPolicyCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

escalationPolicy := buildEscalationPolicyStruct(d)

Expand All @@ -119,7 +119,7 @@ func resourcePagerDutyEscalationPolicyCreate(d *schema.ResourceData, meta interf
}

func resourcePagerDutyEscalationPolicyRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty escalation policy: %s", d.Id())

Expand Down Expand Up @@ -149,7 +149,7 @@ func resourcePagerDutyEscalationPolicyRead(d *schema.ResourceData, meta interfac
}

func resourcePagerDutyEscalationPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

escalationPolicy := buildEscalationPolicyStruct(d)

Expand All @@ -170,7 +170,7 @@ func resourcePagerDutyEscalationPolicyUpdate(d *schema.ResourceData, meta interf
}

func resourcePagerDutyEscalationPolicyDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Deleting PagerDuty escalation policy: %s", d.Id())

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/resource_pagerduty_escalation_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestAccPagerDutyEscalationPolicyWithTeams_Basic(t *testing.T) {
}

func testAccCheckPagerDutyEscalationPolicyDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()
for _, r := range s.RootModule().Resources {
if r.Type != "pagerduty_escalation_policy" {
continue
Expand All @@ -179,7 +179,7 @@ func testAccCheckPagerDutyEscalationPolicyExists(n string) resource.TestCheckFun
return fmt.Errorf("No Escalation Policy ID is set")
}

client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()

found, _, err := client.EscalationPolicies.Get(rs.Primary.ID, &pagerduty.GetEscalationPolicyOptions{})
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pagerduty/resource_pagerduty_event_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func buildEventRuleStruct(d *schema.ResourceData) *pagerduty.EventRule {
}

func resourcePagerDutyEventRuleCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

eventRule := buildEventRuleStruct(d)

Expand All @@ -79,7 +79,7 @@ func resourcePagerDutyEventRuleCreate(d *schema.ResourceData, meta interface{})
}

func resourcePagerDutyEventRuleRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty event rule: %s", d.Id())

Expand Down Expand Up @@ -114,7 +114,7 @@ func resourcePagerDutyEventRuleRead(d *schema.ResourceData, meta interface{}) er
})
}
func resourcePagerDutyEventRuleUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

eventRule := buildEventRuleStruct(d)

Expand All @@ -128,7 +128,7 @@ func resourcePagerDutyEventRuleUpdate(d *schema.ResourceData, meta interface{})
}

func resourcePagerDutyEventRuleDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Deleting PagerDuty event rule: %s", d.Id())

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/resource_pagerduty_event_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestAccPagerDutyEventRule_Basic(t *testing.T) {
}

func testAccCheckPagerDutyEventRuleDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()
for _, r := range s.RootModule().Resources {
if r.Type != "pagerduty_event_rule" {
continue
Expand Down Expand Up @@ -104,7 +104,7 @@ func testAccCheckPagerDutyEventRuleExists(n string) resource.TestCheckFunc {
return fmt.Errorf("No Event Rule ID is set")
}

client := testAccProvider.Meta().(*pagerduty.Client)
client, _ := testAccProvider.Meta().(*Config).Client()
resp, _, err := client.EventRules.List()
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions pagerduty/resource_pagerduty_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func buildExtensionStruct(d *schema.ResourceData) *pagerduty.Extension {
}

func resourcePagerDutyExtensionCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

extension := buildExtensionStruct(d)

Expand All @@ -104,7 +104,7 @@ func resourcePagerDutyExtensionCreate(d *schema.ResourceData, meta interface{})
}

func resourcePagerDutyExtensionRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Reading PagerDuty extension %s", d.Id())

Expand Down Expand Up @@ -138,7 +138,7 @@ func resourcePagerDutyExtensionRead(d *schema.ResourceData, meta interface{}) er
}

func resourcePagerDutyExtensionUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

extension := buildExtensionStruct(d)

Expand All @@ -152,7 +152,7 @@ func resourcePagerDutyExtensionUpdate(d *schema.ResourceData, meta interface{})
}

func resourcePagerDutyExtensionDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

log.Printf("[INFO] Deleting PagerDuty extension %s", d.Id())

Expand All @@ -170,7 +170,7 @@ func resourcePagerDutyExtensionDelete(d *schema.ResourceData, meta interface{})
}

func resourcePagerDutyExtensionImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
client := meta.(*pagerduty.Client)
client, _ := meta.(*Config).Client()

extension, _, err := client.Extensions.Get(d.Id())

Expand Down
Loading

0 comments on commit 1583820

Please sign in to comment.