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

Upgrade Terraform Plugin SDK to v2 #375

Merged
merged 20 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d2de409
`tf-sdk-migrator v2upgrade`
pdecat Aug 18, 2021
6ce481d
`go mod vendor`
pdecat Aug 18, 2021
39b8a58
Removal of helper/schema.Schema.Removed, see https://www.terraform.io…
pdecat Aug 18, 2021
a45b5b9
Removal of the terraform.ResourceProvider Interface, see https://www.…
pdecat Aug 18, 2021
5ae75e8
Removal of Deprecated Validation Functions, see https://www.terraform…
pdecat Aug 18, 2021
10f2914
More Robust Validation of helper/schema.TypeMap Elems, see https://ww…
pdecat Aug 18, 2021
93e1c71
Upgrade terraform-plugin-sdk and transitively terraform-json to get h…
pdecat Aug 18, 2021
f187896
Fix `panic: alert_grouping_timeout: '' expected type 'int', got uncon…
pdecat Aug 18, 2021
6093877
Fix `Error: Output refers to sensitive values`
pdecat Aug 18, 2021
7b7f7cb
Fix `panic: Invalid address to set: []string{"address"}` for `address…
pdecat Aug 18, 2021
604a0e2
Fix `panic: Invalid address to set: []string{"summary"}` formissing `…
pdecat Aug 18, 2021
596ce75
Fix `panic: extension_schema: '' expected type 'string', got unconver…
pdecat Aug 18, 2021
fc6c910
Fix `panic: Invalid address to set: []string{"summary"}` for missing …
pdecat Aug 18, 2021
9f50ca3
Fix `panic: extension_schema: '' expected type 'string', got unconver…
pdecat Aug 18, 2021
51d0e3c
Fix `An argument named "contact_method" is not expected here.` error:
pdecat Aug 19, 2021
32fa231
Fix `panic: Invalid address to set: []string{"type"}` error:
pdecat Aug 19, 2021
d3921e0
Do not set service.AlertGroupingParameters to an empty struct if aler…
pdecat Aug 20, 2021
6ae57df
Fix `panic: alert_grouping_timeout: '' expected type 'string', got un…
pdecat Aug 20, 2021
84e84f9
Fix `pagerduty_service.foo: Attribute 'alert_grouping_timeout' found …
pdecat Aug 20, 2021
9b6fc67
Fix `cannot use func literal (type func(*schema.ResourceDiff, interfa…
pdecat Sep 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
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/hashicorp/terraform-plugin-sdk/v2 v2.7.1
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
Expand Down
234 changes: 149 additions & 85 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/hashicorp/terraform-plugin-sdk/plugin"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/terraform-providers/terraform-provider-pagerduty/pagerduty"
)

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_business_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_business_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyBusinessService_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_escalation_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyEscalationPolicy_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_extension_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_extension_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

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

func TestAccDataSourcePagerDutyExtensionSchema_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pagerduty
import (
"testing"

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

func TestAccDataSourcePagerDutyPriority_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyRuleset_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"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"
)

func TestAccDataSourcePagerDutySchedule_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_service_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
9 changes: 5 additions & 4 deletions pagerduty/data_source_pagerduty_service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyIntegration_Basic(t *testing.T) {
Expand Down Expand Up @@ -101,7 +101,8 @@ data "pagerduty_service_integration" "service_integration" {
}

output "output_id" {
value = data.pagerduty_service_integration.service_integration.integration_key
value = data.pagerduty_service_integration.service_integration.integration_key
sensitive = true
}
`, service, serviceIntegration)
}
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyService_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyTeam_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/data_source_pagerduty_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand Down
31 changes: 28 additions & 3 deletions pagerduty/data_source_pagerduty_user_contact_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand All @@ -29,6 +29,31 @@ func dataSourcePagerDutyUserContactMethod() *schema.Resource {
Required: true,
Description: "The type of the contact method",
},

"address": {
Type: schema.TypeString,
Computed: true,
},
"blacklisted": {
Type: schema.TypeBool,
Computed: true,
},
"country_code": {
Type: schema.TypeInt,
Computed: true,
},
"device_type": {
Type: schema.TypeString,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
},
"send_short_email": {
Type: schema.TypeBool,
Computed: true,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These attributes were already documented but not implemented (and SDK v2 no longer accepts assignments to inexistent attributes)

},
}
}
Expand Down Expand Up @@ -72,11 +97,11 @@ func dataSourcePagerDutyUserContactMethodRead(d *schema.ResourceData, meta inter
d.Set("address", found.Address)
d.Set("blacklisted", found.BlackListed)
d.Set("country_code", found.CountryCode)
d.Set("device_type", found.DeviceType)
d.Set("enabled", found.Enabled)
d.Set("label", found.Label)
d.Set("send_short_email", found.SendShortEmail)
d.Set("type", found.Type)
d.Set("device_type", found.DeviceType)

return nil
})
Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_user_contact_method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyUserContactMethod_Basic(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions pagerduty/data_source_pagerduty_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ 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"
"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"
)

func TestAccDataSourcePagerDutyUser_Basic(t *testing.T) {
Expand Down
13 changes: 4 additions & 9 deletions pagerduty/data_source_pagerduty_vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/heimweh/go-pagerduty/pagerduty"
)

Expand All @@ -17,11 +17,6 @@ func dataSourcePagerDutyVendor() *schema.Resource {
Read: dataSourcePagerDutyVendorRead,

Schema: map[string]*schema.Schema{
"name_regex": {
Type: schema.TypeString,
Optional: true,
Removed: "Use `name` instead. This attribute will be removed in a future version",
},
"name": {
Type: schema.TypeString,
Required: true,
Expand All @@ -47,13 +42,13 @@ func dataSourcePagerDutyVendorRead(d *schema.ResourceData, meta interface{}) err
return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, _, err := client.Vendors.List(o)
if err != nil {
if (isErrCode(err, 429)) {
if isErrCode(err, 429) {
// Delaying retry by 30s as recommended by PagerDuty
// https://developer.pagerduty.com/docs/rest-api-v2/rate-limiting/#what-are-possible-workarounds-to-the-events-api-rate-limit
time.Sleep(30 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
}

Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_vendor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pagerduty
import (
"testing"

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

func TestAccDataSourcePagerDutyVendor_Basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pagerduty/import_pagerduty_business_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ 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/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccPagerDutyBusinessService_import(t *testing.T) {
Expand Down
Loading