Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
[MCTB-6735] Update with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
mwidera committed Feb 27, 2024
1 parent 35782b8 commit d915e01
Show file tree
Hide file tree
Showing 800 changed files with 407 additions and 83,098 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.21"
-
name: Import GPG key
id: import_gpg
Expand All @@ -27,7 +27,7 @@ jobs:
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
Expand Down
33 changes: 17 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ module github.com/nordcloud/terraform-provider-pagerduty

go 1.21

toolchain go1.21.6

require (
github.com/PagerDuty/go-pagerduty v1.8.1-0.20240118191642-803061c27c20
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hc-install v0.6.2
github.com/hashicorp/hc-install v0.6.3
github.com/hashicorp/terraform-exec v0.20.0
github.com/hashicorp/terraform-json v0.20.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/hashicorp/terraform-json v0.21.0
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.22.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
github.com/nordcloud/go-pagerduty v1.5.3
)

require (
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
Expand All @@ -33,12 +37,7 @@ require (
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-framework v1.5.0 // indirect
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.22.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-mux v0.15.0 // indirect
github.com/hashicorp/terraform-plugin-testing v1.6.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -60,15 +59,17 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
github.com/zclconf/go-cty v1.14.2 // indirect
go.mongodb.org/mongo-driver v1.13.1 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.0 // indirect
Expand Down
106 changes: 48 additions & 58 deletions go.sum

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package main

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"context"
"log"

"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"

"github.com/nordcloud/terraform-provider-pagerduty/pagerduty"
pagerdutyplugin "github.com/nordcloud/terraform-provider-pagerduty/pagerdutyplugin"
)

func main() {
Expand Down
12 changes: 4 additions & 8 deletions pagerduty/data_source_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"time"

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

Expand Down Expand Up @@ -105,17 +105,13 @@ func dataSourcePagerDutyAutomationActionsActionRead(d *schema.ResourceData, meta

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

return retry.Retry(2*time.Minute, func() *retry.RetryError {
return resource.Retry(1*time.Minute, func() *resource.RetryError {
automationActionsAction, _, err := client.AutomationActionsAction.Get(d.Get("id").(string))
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
}

// 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 retry.RetryableError(err)
return resource.RetryableError(err)
}

d.SetId(automationActionsAction.ID)
Expand All @@ -130,7 +126,7 @@ func dataSourcePagerDutyAutomationActionsActionRead(d *schema.ResourceData, meta

f_adr := flattenActionDataReference(automationActionsAction.ActionDataReference)
if err := d.Set("action_data_reference", f_adr); err != nil {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

if automationActionsAction.ModifyTime != nil {
Expand Down
10 changes: 3 additions & 7 deletions pagerduty/data_source_pagerduty_automation_actions_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"time"

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

Expand Down Expand Up @@ -60,17 +60,13 @@ func dataSourcePagerDutyAutomationActionsRunnerRead(d *schema.ResourceData, meta

log.Printf("[INFO] Reading PagerDuty automation actions runner")

return retry.Retry(2*time.Minute, func() *retry.RetryError {
return resource.Retry(1*time.Minute, func() *resource.RetryError {
runner, _, err := client.AutomationActionsRunner.Get(d.Get("id").(string))
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
}

// 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 retry.RetryableError(err)
return resource.RetryableError(err)
}

d.SetId(runner.ID)
Expand Down
2 changes: 1 addition & 1 deletion pagerduty/data_source_pagerduty_event_orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func dataSourcePagerDutyEventOrchestrationRead(ctx context.Context, d *schema.Re
// since the list ndpoint does not return it
orch, _, err := client.EventOrchestrations.Get(found.ID)
if err != nil {
return retry.RetryableError(err)
return resource.RetryableError(err)
}

d.SetId(orch.ID)
Expand Down
19 changes: 12 additions & 7 deletions pagerduty/data_source_pagerduty_event_orchestration_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nordcloud/go-pagerduty/pagerduty"
)
Expand Down Expand Up @@ -82,16 +82,16 @@ func getEventOrchestrationIntegrationById(ctx context.Context, d *schema.Resourc
return diag.FromErr(err)
}

retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
retryErr := resource.RetryContext(ctx, 2*time.Minute, func() *resource.RetryError {
log.Printf("[INFO] Reading Integration data source by ID '%s' for PagerDuty Event Orchestration '%s'", id, oid)

if integration, _, err := client.EventOrchestrationIntegrations.GetContext(ctx, oid, id); err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

time.Sleep(30 * time.Second)
return retry.RetryableError(err)
return resource.RetryableError(err)
} else if integration != nil {
d.SetId(integration.ID)
setEventOrchestrationIntegrationProps(d, integration)
Expand All @@ -116,17 +116,18 @@ func getEventOrchestrationIntegrationByLabel(ctx context.Context, d *schema.Reso
return diag.FromErr(err)
}

retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
retryErr := resource.RetryContext(ctx, 2*time.Minute, func() *resource.RetryError {
log.Printf("[INFO] Reading Integration data source by label '%s' for PagerDuty Event Orchestration '%s'", lbl, oid)

resp, _, err := client.EventOrchestrationIntegrations.ListContext(ctx, oid)

if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

time.Sleep(30 * time.Second)
return retry.RetryableError(err)
return resource.RetryableError(err)
}

var matches []*pagerduty.EventOrchestrationIntegration
Expand All @@ -149,6 +150,10 @@ func getEventOrchestrationIntegrationByLabel(ctx context.Context, d *schema.Reso
return resource.NonRetryableError(
fmt.Errorf("ambiguous Integration label: '%s'. Found %v Integrations with this label on Event Orchestration '%s'. Please use the Integration ID instead or make Integration labels unique within Event Orchestration", lbl, count, oid),
)
}

found := matches[0]
d.SetId(found.ID)
setEventOrchestrationIntegrationProps(d, found)

return nil
Expand Down
16 changes: 8 additions & 8 deletions pagerduty/data_source_pagerduty_event_orchestrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nordcloud/go-pagerduty/pagerduty"
)
Expand Down Expand Up @@ -85,19 +85,19 @@ func dataSourcePagerDutyEventOrchestrationsRead(d *schema.ResourceData, meta int
nameFilter := d.Get("name_filter").(string)

var eoList []*pagerduty.EventOrchestration
retryErr := retry.Retry(2*time.Minute, func() *retry.RetryError {
retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, _, err := client.EventOrchestrations.List()
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

return retry.RetryableError(err)
return resource.RetryableError(err)
}

re, err := regexp.Compile(nameFilter)
if err != nil {
return retry.NonRetryableError(fmt.Errorf("invalid regexp for name_filter provided %s", nameFilter))
return resource.NonRetryableError(fmt.Errorf("invalid regexp for name_filter provided %s", nameFilter))
}
for _, orchestration := range resp.Orchestrations {
if re.MatchString(orchestration.Name) {
Expand All @@ -119,14 +119,14 @@ func dataSourcePagerDutyEventOrchestrationsRead(d *schema.ResourceData, meta int
for _, orchestration := range eoList {
// Get orchestration matched by ID so we can set the integrations property
// since the list endpoint does not return it
retryErr := retry.Retry(2*time.Minute, func() *retry.RetryError {
retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError {
orch, _, err := client.EventOrchestrations.Get(orchestration.ID)
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

return retry.RetryableError(err)
return resource.RetryableError(err)
}
orchestrations = append(orchestrations, orch)
return nil
Expand Down
4 changes: 0 additions & 4 deletions pagerduty/data_source_pagerduty_extension_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import (
"strings"
"time"

<<<<<<< HEAD
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"

"context"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
=======
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
>>>>>>> upstream/master
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nordcloud/go-pagerduty/pagerduty"
)
Expand Down
12 changes: 6 additions & 6 deletions pagerduty/data_source_pagerduty_incident_custom_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nordcloud/go-pagerduty/pagerduty"
)
Expand Down Expand Up @@ -51,17 +51,17 @@ func dataSourcePagerDutyIncidentCustomFieldRead(ctx context.Context, d *schema.R

searchName := d.Get("name").(string)

err = retry.RetryContext(ctx, 5*time.Minute, func() *retry.RetryError {
err = resource.RetryContext(ctx, 5*time.Minute, func() *resource.RetryError {
resp, _, err := client.IncidentCustomFields.ListContext(ctx, nil)
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

// 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 retry.RetryableError(err)
return resource.RetryableError(err)
}

var found *pagerduty.IncidentCustomField
Expand All @@ -74,14 +74,14 @@ func dataSourcePagerDutyIncidentCustomFieldRead(ctx context.Context, d *schema.R
}

if found == nil {
return retry.NonRetryableError(
return resource.NonRetryableError(
fmt.Errorf("unable to locate any field with name: %s", searchName),
)
}

err = flattenIncidentCustomField(d, found)
if err != nil {
return retry.NonRetryableError(err)
return resource.NonRetryableError(err)
}

return nil
Expand Down
Loading

0 comments on commit d915e01

Please sign in to comment.