Skip to content

Commit 5931b5f

Browse files
committed
Add resource pagerduty service dependency
1 parent 7671607 commit 5931b5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5459
-5
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/hashicorp/terraform-exec v0.20.0
1111
github.com/hashicorp/terraform-json v0.20.0
1212
github.com/hashicorp/terraform-plugin-framework v1.5.0
13+
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
1314
github.com/hashicorp/terraform-plugin-go v0.20.0
1415
github.com/hashicorp/terraform-plugin-mux v0.13.0
1516
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ github.com/hashicorp/terraform-json v0.20.0 h1:cJcvn4gIOTi0SD7pIy+xiofV1zFA3hza+
7575
github.com/hashicorp/terraform-json v0.20.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
7676
github.com/hashicorp/terraform-plugin-framework v1.5.0 h1:8kcvqJs/x6QyOFSdeAyEgsenVOUeC/IyKpi2ul4fjTg=
7777
github.com/hashicorp/terraform-plugin-framework v1.5.0/go.mod h1:6waavirukIlFpVpthbGd2PUNYaFedB0RwW3MDzJ/rtc=
78+
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
79+
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
7880
github.com/hashicorp/terraform-plugin-go v0.20.0 h1:oqvoUlL+2EUbKNsJbIt3zqqZ7wi6lzn4ufkn/UA51xQ=
7981
github.com/hashicorp/terraform-plugin-go v0.20.0/go.mod h1:Rr8LBdMlY53a3Z/HpP+ZU3/xCDqtKNCkeI9qOyT10QE=
8082
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=

pagerduty/provider.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ func Provider() *schema.Provider {
119119
"pagerduty_ruleset": resourcePagerDutyRuleset(),
120120
"pagerduty_ruleset_rule": resourcePagerDutyRulesetRule(),
121121
"pagerduty_business_service": resourcePagerDutyBusinessService(),
122-
"pagerduty_service_dependency": resourcePagerDutyServiceDependency(),
123122
"pagerduty_response_play": resourcePagerDutyResponsePlay(),
124123
"pagerduty_tag": resourcePagerDutyTag(),
125124
"pagerduty_tag_assignment": resourcePagerDutyTagAssignment(),

pagerdutyplugin/provider.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import (
77
"os"
88
"strings"
99

10+
"github.com/PagerDuty/go-pagerduty"
1011
"github.com/hashicorp/terraform-plugin-framework/datasource"
1112
"github.com/hashicorp/terraform-plugin-framework/provider"
1213
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
1314
"github.com/hashicorp/terraform-plugin-framework/resource"
1415
"github.com/hashicorp/terraform-plugin-framework/types"
1516
)
1617

17-
type Provider struct{}
18+
type Provider struct {
19+
client *pagerduty.Client
20+
}
1821

1922
func (p *Provider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
2023
resp.TypeName = "pagerduty"
@@ -53,10 +56,12 @@ func (p *Provider) DataSources(ctx context.Context) [](func() datasource.DataSou
5356
}
5457

5558
func (p *Provider) Resources(ctx context.Context) [](func() resource.Resource) {
56-
return [](func() resource.Resource){}
59+
return [](func() resource.Resource){
60+
func() resource.Resource { return &resourceServiceDependency{} },
61+
}
5762
}
5863

59-
func New() provider.Provider {
64+
func New() *Provider {
6065
return &Provider{}
6166
}
6267

@@ -159,7 +164,9 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
159164
if err != nil {
160165
resp.Diagnostics.AddError("Cannot obtain plugin client", err.Error())
161166
}
167+
p.client = client
162168
resp.DataSourceData = client
169+
resp.ResourceData = client
163170
}
164171

165172
type UseAppOauthScopedToken struct {

pagerdutyplugin/provider_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ func testAccCheckAttributes(n string, fn func(map[string]string) error) resource
3636
}
3737
}
3838

39+
var testAccProvider = New()
40+
3941
func testAccProtoV5ProviderFactories() map[string]func() (tfprotov5.ProviderServer, error) {
4042
return map[string]func() (tfprotov5.ProviderServer, error){
4143
"pagerduty": func() (tfprotov5.ProviderServer, error) {
4244
ctx := context.Background()
4345
providers := []func() tfprotov5.ProviderServer{
4446
pd.Provider().GRPCProvider,
45-
providerserver.NewProtocol5(New()),
47+
providerserver.NewProtocol5(testAccProvider),
4648
}
4749

4850
muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...)

0 commit comments

Comments
 (0)