Skip to content

Commit

Permalink
Update to newer GO client version
Browse files Browse the repository at this point in the history
  • Loading branch information
c-kaieong committed Mar 21, 2024
1 parent 41548fa commit e0d0a50
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
)

replace github.com/heimweh/go-pagerduty => github.com/c-kaieong/go-pagerduty v0.0.0-20240311200326-919db4bc1266
replace github.com/heimweh/go-pagerduty => github.com/c-kaieong/go-pagerduty v0.0.0-20240321202501-cb1dc594997d
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/c-kaieong/go-pagerduty v0.0.0-20240311200326-919db4bc1266 h1:8b11EQOZpqOS6GgFDSF+3Nxo5kQ5DIFvNEZPAJtdTxA=
github.com/c-kaieong/go-pagerduty v0.0.0-20240311200326-919db4bc1266/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/c-kaieong/go-pagerduty v0.0.0-20240321202501-cb1dc594997d h1:Mk6+b9U0C4JlW3yt9YOeTRat0/5jSmNdyXmDSUDw0jI=
github.com/c-kaieong/go-pagerduty v0.0.0-20240321202501-cb1dc594997d/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
Expand Down
14 changes: 7 additions & 7 deletions pagerduty/event_orchestration_cache_variable_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func fetchPagerDutyEventOrchestrationCacheVariable(ctx context.Context, d *schem
return nil, err
}

if cacheVariable, _, err := client.EventOrchestrationCacheVariables.GetContext(ctx, cacheVariableType, oid, id); err != nil {
if cacheVariable, _, err := client.EventOrchestrationCacheVariables.Get(ctx, cacheVariableType, oid, id); err != nil {
return nil, err
} else if cacheVariable != nil {
d.SetId(id)
Expand Down Expand Up @@ -253,7 +253,7 @@ func resourceEventOrchestrationCacheVariableCreate(ctx context.Context, d *schem
retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
log.Printf("[INFO] Creating Cache Variable '%s' for PagerDuty Event Orchestration '%s'", payload.Name, oid)

if cacheVariable, _, err := client.EventOrchestrationCacheVariables.CreateContext(ctx, cacheVariableType, oid, payload); err != nil {
if cacheVariable, _, err := client.EventOrchestrationCacheVariables.Create(ctx, cacheVariableType, oid, payload); err != nil {
if isErrCode(err, http.StatusBadRequest) || isErrCode(err, http.StatusNotFound) || isErrCode(err, http.StatusForbidden) {
return retry.NonRetryableError(err)
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func resourceEventOrchestrationCacheVariableUpdate(ctx context.Context, d *schem

retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
log.Printf("[INFO] Updating Cache Variable '%s' for PagerDuty Event Orchestration: %s", id, oid)
if cacheVariable, _, err := client.EventOrchestrationCacheVariables.UpdateContext(ctx, cacheVariableType, oid, id, payload); err != nil {
if cacheVariable, _, err := client.EventOrchestrationCacheVariables.Update(ctx, cacheVariableType, oid, id, payload); err != nil {
if isErrCode(err, http.StatusBadRequest) || isErrCode(err, http.StatusNotFound) || isErrCode(err, http.StatusForbidden) {
return retry.NonRetryableError(err)
}
Expand Down Expand Up @@ -347,15 +347,15 @@ func resourceEventOrchestrationCacheVariableDelete(ctx context.Context, d *schem

retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
log.Printf("[INFO] Deleting Cache Variable '%s' for PagerDuty Event Orchestration: %s", id, oid)
if _, err := client.EventOrchestrationCacheVariables.DeleteContext(ctx, cacheVariableType, oid, id); err != nil {
if _, err := client.EventOrchestrationCacheVariables.Delete(ctx, cacheVariableType, oid, id); err != nil {
if isErrCode(err, http.StatusBadRequest) || isErrCode(err, http.StatusNotFound) || isErrCode(err, http.StatusForbidden) {
return retry.NonRetryableError(err)
}

return retry.RetryableError(err)
} else {
// Try reading an cache variable after deletion, retry if still found:
if cacheVariable, _, readErr := client.EventOrchestrationCacheVariables.GetContext(ctx, cacheVariableType, oid, id); readErr == nil && cacheVariable != nil {
if cacheVariable, _, readErr := client.EventOrchestrationCacheVariables.Get(ctx, cacheVariableType, oid, id); readErr == nil && cacheVariable != nil {
log.Printf("[WARN] Cache Variable '%s' still exists on PagerDuty Event Orchestration '%s'. Retrying deletion...", id, oid)
return retry.RetryableError(fmt.Errorf("Cache Variable '%s' still exists on PagerDuty Event Orchestration '%s'.", id, oid))
}
Expand Down Expand Up @@ -417,7 +417,7 @@ func getEventOrchestrationCacheVariableById(ctx context.Context, d *schema.Resou
retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
log.Printf("[INFO] Reading Cache Variable data source by ID '%s' for PagerDuty Event Orchestration '%s'", id, oid)

if cacheVariable, _, err := client.EventOrchestrationCacheVariables.GetContext(ctx, cacheVariableType, oid, id); err != nil {
if cacheVariable, _, err := client.EventOrchestrationCacheVariables.Get(ctx, cacheVariableType, oid, id); err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
}
Expand Down Expand Up @@ -451,7 +451,7 @@ func getEventOrchestrationCacheVariableByName(ctx context.Context, d *schema.Res
retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
log.Printf("[INFO] Reading Cache Variable data source by name '%s' for PagerDuty Event Orchestration '%s'", name, oid)

resp, _, err := client.EventOrchestrationCacheVariables.ListContext(ctx, cacheVariableType, oid)
resp, _, err := client.EventOrchestrationCacheVariables.List(ctx, cacheVariableType, oid)
if err != nil {
if isErrCode(err, http.StatusBadRequest) {
return retry.NonRetryableError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableDestroy(s *terraf
if r.Type != "pagerduty_event_orchestration_global_cache_variable" {
continue
}
if _, _, err := client.EventOrchestrationCacheVariables.GetContext(context.Background(), pagerduty.CacheVariableTypeGlobal, r.Primary.Attributes["event_orchestration"], r.Primary.ID); err == nil {
if _, _, err := client.EventOrchestrationCacheVariables.Get(context.Background(), pagerduty.CacheVariableTypeGlobal, r.Primary.Attributes["event_orchestration"], r.Primary.ID); err == nil {
return fmt.Errorf("Event Orchestration Cache Variables still exist")
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func testAccCheckPagerDutyEventOrchestrationGlobalCacheVariableID(cv, orchn stri
id := ir.Primary.ID

client, _ := testAccProvider.Meta().(*Config).Client()
i, _, err := client.EventOrchestrationCacheVariables.GetContext(context.Background(), pagerduty.CacheVariableTypeGlobal, oid, id)
i, _, err := client.EventOrchestrationCacheVariables.Get(context.Background(), pagerduty.CacheVariableTypeGlobal, oid, id)
eo, _, _ := client.EventOrchestrations.Get(eor.Primary.ID)

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func testAccCheckPagerDutyEventOrchestrationServiceCacheVariableDestroy(s *terra
if r.Type != "pagerduty_event_orchestration_service_cache_variable" {
continue
}
if _, _, err := client.EventOrchestrationCacheVariables.GetContext(context.Background(), pagerduty.CacheVariableTypeService, r.Primary.Attributes["event_orchestration"], r.Primary.ID); err == nil {
if _, _, err := client.EventOrchestrationCacheVariables.Get(context.Background(), pagerduty.CacheVariableTypeService, r.Primary.Attributes["event_orchestration"], r.Primary.ID); err == nil {
return fmt.Errorf("Event Orchestration Cache Variables still exist")
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func testAccCheckPagerDutyEventOrchestrationServiceCacheVariableID(cv, svcn stri
id := ir.Primary.ID

client, _ := testAccProvider.Meta().(*Config).Client()
i, _, err := client.EventOrchestrationCacheVariables.GetContext(context.Background(), pagerduty.CacheVariableTypeService, sid, id)
i, _, err := client.EventOrchestrationCacheVariables.Get(context.Background(), pagerduty.CacheVariableTypeService, sid, id)
svc, _, _ := client.Services.Get(svcr.Primary.ID, &pagerduty.GetServiceOptions{})

if err != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ github.com/hashicorp/terraform-svchost
# github.com/hashicorp/yamux v0.1.1
## explicit; go 1.15
github.com/hashicorp/yamux
# github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff => github.com/c-kaieong/go-pagerduty v0.0.0-20240311200326-919db4bc1266
# github.com/heimweh/go-pagerduty v0.0.0-20240226201314-bfc8dce0a3ff => github.com/c-kaieong/go-pagerduty v0.0.0-20240321202501-cb1dc594997d
## explicit; go 1.17
github.com/heimweh/go-pagerduty/pagerduty
github.com/heimweh/go-pagerduty/persistentconfig
Expand Down Expand Up @@ -549,4 +549,4 @@ google.golang.org/protobuf/types/known/timestamppb
# gopkg.in/ini.v1 v1.67.0
## explicit
gopkg.in/ini.v1
# github.com/heimweh/go-pagerduty => github.com/c-kaieong/go-pagerduty v0.0.0-20240311200326-919db4bc1266
# github.com/heimweh/go-pagerduty => github.com/c-kaieong/go-pagerduty v0.0.0-20240321202501-cb1dc594997d

0 comments on commit e0d0a50

Please sign in to comment.