Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
c-kaieong committed Feb 20, 2024
1 parent 915502a commit 844a929
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 60 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ require (
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

replace github.com/heimweh/go-pagerduty => github.com/c-kaieong/go-pagerduty v0.0.0-20240213182338-5279d0649125
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +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-20240213182338-5279d0649125 h1:2o7CkWpFurf69oUnPH8Fq9Y60fCVG1OuQU5KLfgm2ys=
github.com/c-kaieong/go-pagerduty v0.0.0-20240213182338-5279d0649125/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 Expand Up @@ -93,8 +95,6 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 h1:+JY7wpGAsTe/r51/nTdo3pQQ2Wj4cTXpsQfij1JK2gc=
github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76/go.mod h1:r59w5iyN01Qvi734yA5hZldbSeJJmsJzee/1kQ/MK7s=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
26 changes: 7 additions & 19 deletions pagerduty/event_orchestration_cache_variable_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"time"

"github.com/hashicorp/go-cty/cty"
"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/schema"
Expand Down Expand Up @@ -41,23 +40,6 @@ var resourceEventOrchestrationCacheVariableConfigurationSchema = map[string]*sch
"ttl_seconds": {
Type: schema.TypeInt,
Optional: true,
ValidateDiagFunc: func(v interface{}, p cty.Path) diag.Diagnostics {
var diags diag.Diagnostics
min := 1
max := 84000

value := v.(int)
valid := value >= min && value <= max

if !valid {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: fmt.Sprintf("%#v is an invalid value. Must be between %#v and %#v (inclusive)", value, min, max),
AttributePath: p,
})
}
return diags
},
},
}

Expand Down Expand Up @@ -230,8 +212,14 @@ func resourceEventOrchestrationCacheVariableImport(ctx context.Context, d *schem
return []*schema.ResourceData{}, err
}

parent_identifier := "orchestration_id"

if cacheVariableType == pagerduty.CacheVariableTypeService {
parent_identifier = "service_id"
}

if oid == "" || id == "" {
return []*schema.ResourceData{}, fmt.Errorf("Error importing cache variable. Expected import ID format: <orchestration_id>:<cache_variable_id>")
return []*schema.ResourceData{}, fmt.Errorf("Error importing cache variable. Expected import ID format: <%s>:<cache_variable_id>", parent_identifier)
}

retryErr := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
Expand Down

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

78 changes: 40 additions & 38 deletions vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go

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

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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-20240206151700-a2cbd995ef76
# github.com/heimweh/go-pagerduty v0.0.0-20240206151700-a2cbd995ef76 => github.com/c-kaieong/go-pagerduty v0.0.0-20240213182338-5279d0649125
## explicit; go 1.17
github.com/heimweh/go-pagerduty/pagerduty
github.com/heimweh/go-pagerduty/persistentconfig
Expand Down Expand Up @@ -548,3 +548,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-20240213182338-5279d0649125

0 comments on commit 844a929

Please sign in to comment.