Skip to content

Commit e9c6a85

Browse files
committed
chore(sdk): Serve the provider through a mux server
This is in preparation to migrate to the plugin framework.
1 parent 8c0e50a commit e9c6a85

21 files changed

+103
-88
lines changed

cloudamqp/provider_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cloudamqp
22

33
import (
4+
"context"
45
"fmt"
56
"net/http"
67
"net/url"
@@ -9,16 +10,15 @@ import (
910
"testing"
1011

1112
"github.com/cloudamqp/terraform-provider-cloudamqp/cloudamqp/vcr-testing/sanitizer"
13+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
14+
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
1215
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
13-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1416
"github.com/tidwall/gjson"
1517
"gopkg.in/dnaeon/go-vcr.v3/cassette"
1618
"gopkg.in/dnaeon/go-vcr.v3/recorder"
1719
)
1820

1921
var (
20-
testAccProviderFactory map[string]func() (*schema.Provider, error)
21-
2222
mode = recorder.ModeReplayOnly
2323
)
2424

@@ -167,10 +167,19 @@ func cloudamqpResourceTest(t *testing.T, c resource.TestCase) {
167167
return req.URL.Path == "/login"
168168
})
169169

170-
testAccProviderFactory = map[string]func() (*schema.Provider, error){
171-
"cloudamqp": func() (*schema.Provider, error) { return Provider("1.0", rec.GetDefaultClient()), nil },
170+
c.ProtoV5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){
171+
"cloudamqp": func() (tfprotov5.ProviderServer, error) {
172+
ctx := context.Background()
173+
174+
muxServer, err := tf5muxserver.NewMuxServer(ctx, Provider("1.0", rec.GetDefaultClient()).GRPCProvider)
175+
176+
if err != nil {
177+
return nil, err
178+
}
179+
180+
return muxServer.ProviderServer(), nil
181+
},
172182
}
173-
c.ProviderFactories = testAccProviderFactory
174183

175184
resource.Test(t, c)
176185
}

cloudamqp/resource_cloudamqp_alarm_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ func TestAccAlarm_Basic(t *testing.T) {
5858
)
5959

6060
cloudamqpResourceTest(t, resource.TestCase{
61-
PreCheck: func() { testAccPreCheck(t) },
62-
ProviderFactories: testAccProviderFactory,
61+
PreCheck: func() { testAccPreCheck(t) },
6362
Steps: []resource.TestStep{
6463
{
6564
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_aws_eventbridge_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ func TestAccIntegrationAwsEventbridge_Basic(t *testing.T) {
2727
)
2828

2929
cloudamqpResourceTest(t, resource.TestCase{
30-
PreCheck: func() { testAccPreCheck(t) },
31-
ProviderFactories: testAccProviderFactory,
30+
PreCheck: func() { testAccPreCheck(t) },
3231
Steps: []resource.TestStep{
3332
{
3433
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_extra_disk_size_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ func TestAccExtraDiskSize_AWS_Basic(t *testing.T) {
2626
)
2727

2828
cloudamqpResourceTest(t, resource.TestCase{
29-
PreCheck: func() { testAccPreCheck(t) },
30-
ProviderFactories: testAccProviderFactory,
29+
PreCheck: func() { testAccPreCheck(t) },
3130
Steps: []resource.TestStep{
3231
{
3332
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -60,8 +59,7 @@ func TestAccExtraDiskSize_GCE_Basic(t *testing.T) {
6059
)
6160

6261
cloudamqpResourceTest(t, resource.TestCase{
63-
PreCheck: func() { testAccPreCheck(t) },
64-
ProviderFactories: testAccProviderFactory,
62+
PreCheck: func() { testAccPreCheck(t) },
6563
Steps: []resource.TestStep{
6664
{
6765
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -94,8 +92,7 @@ func TestAccExtraDiskSize_Azure_Basic(t *testing.T) {
9492
)
9593

9694
cloudamqpResourceTest(t, resource.TestCase{
97-
PreCheck: func() { testAccPreCheck(t) },
98-
ProviderFactories: testAccProviderFactory,
95+
PreCheck: func() { testAccPreCheck(t) },
9996
Steps: []resource.TestStep{
10097
{
10198
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_instance_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ func TestAccInstance_Basic(t *testing.T) {
3434
)
3535

3636
cloudamqpResourceTest(t, resource.TestCase{
37-
PreCheck: func() { testAccPreCheck(t) },
38-
ProviderFactories: testAccProviderFactory,
37+
PreCheck: func() { testAccPreCheck(t) },
3938
Steps: []resource.TestStep{
4039
{
4140
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -96,8 +95,7 @@ func TestAccInstance_Upgrade(t *testing.T) {
9695
}
9796
)
9897
cloudamqpResourceTest(t, resource.TestCase{
99-
PreCheck: func() { testAccPreCheck(t) },
100-
ProviderFactories: testAccProviderFactory,
98+
PreCheck: func() { testAccPreCheck(t) },
10199
Steps: []resource.TestStep{
102100
{
103101
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -146,8 +144,7 @@ func TestAccInstance_PlanChange(t *testing.T) {
146144
)
147145

148146
cloudamqpResourceTest(t, resource.TestCase{
149-
PreCheck: func() { testAccPreCheck(t) },
150-
ProviderFactories: testAccProviderFactory,
147+
PreCheck: func() { testAccPreCheck(t) },
151148
Steps: []resource.TestStep{
152149
{
153150
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -189,8 +186,7 @@ func TestAccInstance_Downgrade(t *testing.T) {
189186
)
190187

191188
cloudamqpResourceTest(t, resource.TestCase{
192-
PreCheck: func() { testAccPreCheck(t) },
193-
ProviderFactories: testAccProviderFactory,
189+
PreCheck: func() { testAccPreCheck(t) },
194190
Steps: []resource.TestStep{
195191
{
196192
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_integration_log_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ func TestAccIntegrationLog_Basic(t *testing.T) {
5555
)
5656

5757
cloudamqpResourceTest(t, resource.TestCase{
58-
PreCheck: func() { testAccPreCheck(t) },
59-
ProviderFactories: testAccProviderFactory,
58+
PreCheck: func() { testAccPreCheck(t) },
6059
Steps: []resource.TestStep{
6160
{
6261
ExpectNonEmptyPlan: true,

cloudamqp/resource_cloudamqp_integration_metric_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func TestAccIntegrationMetric_Basic(t *testing.T) {
4040
)
4141

4242
cloudamqpResourceTest(t, resource.TestCase{
43-
PreCheck: func() { testAccPreCheck(t) },
44-
ProviderFactories: testAccProviderFactory,
43+
PreCheck: func() { testAccPreCheck(t) },
4544
Steps: []resource.TestStep{
4645
{
4746
ExpectNonEmptyPlan: true,

cloudamqp/resource_cloudamqp_notification_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ func TestAccNotification_Basic(t *testing.T) {
3535
)
3636

3737
cloudamqpResourceTest(t, resource.TestCase{
38-
PreCheck: func() { testAccPreCheck(t) },
39-
ProviderFactories: testAccProviderFactory,
38+
PreCheck: func() { testAccPreCheck(t) },
4039
Steps: []resource.TestStep{
4140
{
4241
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_plugin_community_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func TestAccPluginCommunity_Basic(t *testing.T) {
4040
)
4141

4242
cloudamqpResourceTest(t, resource.TestCase{
43-
PreCheck: func() { testAccPreCheck(t) },
44-
ProviderFactories: testAccProviderFactory,
43+
PreCheck: func() { testAccPreCheck(t) },
4544
Steps: []resource.TestStep{
4645
{
4746
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_plugin_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ func TestAccPlugin_Basic(t *testing.T) {
4040
)
4141

4242
cloudamqpResourceTest(t, resource.TestCase{
43-
PreCheck: func() { testAccPreCheck(t) },
44-
ProviderFactories: testAccProviderFactory,
43+
PreCheck: func() { testAccPreCheck(t) },
4544
Steps: []resource.TestStep{
4645
{
4746
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_rabbitmq_configuration_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ func TestAccRabbitMqConfiguration_Basic(t *testing.T) {
2727
)
2828

2929
cloudamqpResourceTest(t, resource.TestCase{
30-
PreCheck: func() { testAccPreCheck(t) },
31-
ProviderFactories: testAccProviderFactory,
30+
PreCheck: func() { testAccPreCheck(t) },
3231
Steps: []resource.TestStep{
3332
{
3433
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -70,8 +69,7 @@ func TestAccRabbitMqConfiguration_LogExhangeLevel(t *testing.T) {
7069
)
7170

7271
cloudamqpResourceTest(t, resource.TestCase{
73-
PreCheck: func() { testAccPreCheck(t) },
74-
ProviderFactories: testAccProviderFactory,
72+
PreCheck: func() { testAccPreCheck(t) },
7573
Steps: []resource.TestStep{
7674
{
7775
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_security_firewall_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ func TestAccFirewall_Basic(t *testing.T) {
3939
)
4040

4141
cloudamqpResourceTest(t, resource.TestCase{
42-
PreCheck: func() { testAccPreCheck(t) },
43-
ProviderFactories: testAccProviderFactory,
42+
PreCheck: func() { testAccPreCheck(t) },
4443
Steps: []resource.TestStep{
4544
{
4645
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_upgrade_lavinmq_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ func TestAccUpgradeLavinMQ(t *testing.T) {
4848
)
4949

5050
cloudamqpResourceTest(t, resource.TestCase{
51-
PreCheck: func() { testAccPreCheck(t) },
52-
ProviderFactories: testAccProviderFactory,
51+
PreCheck: func() { testAccPreCheck(t) },
5352
Steps: []resource.TestStep{
5453
{
5554
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_upgrade_rabbitmq_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ func TestAccUpgradeRabbitMQ_Latest(t *testing.T) {
5757
)
5858

5959
cloudamqpResourceTest(t, resource.TestCase{
60-
PreCheck: func() { testAccPreCheck(t) },
61-
ProviderFactories: testAccProviderFactory,
60+
PreCheck: func() { testAccPreCheck(t) },
6261
Steps: []resource.TestStep{
6362
{
6463
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -151,8 +150,7 @@ func TestAccUpgradeRabbitMQ_Specific(t *testing.T) {
151150
)
152151

153152
cloudamqpResourceTest(t, resource.TestCase{
154-
PreCheck: func() { testAccPreCheck(t) },
155-
ProviderFactories: testAccProviderFactory,
153+
PreCheck: func() { testAccPreCheck(t) },
156154
Steps: []resource.TestStep{
157155
{
158156
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_vpc_connect_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ func TestAccVpcConnect_AWS_Basic(t *testing.T) {
4343
)
4444

4545
cloudamqpResourceTest(t, resource.TestCase{
46-
PreCheck: func() { testAccPreCheck(t) },
47-
ProviderFactories: testAccProviderFactory,
46+
PreCheck: func() { testAccPreCheck(t) },
4847
Steps: []resource.TestStep{
4948
{
5049
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -98,8 +97,7 @@ func TestAccVpcConnect_Azure_Basic(t *testing.T) {
9897
)
9998

10099
cloudamqpResourceTest(t, resource.TestCase{
101-
PreCheck: func() { testAccPreCheck(t) },
102-
ProviderFactories: testAccProviderFactory,
100+
PreCheck: func() { testAccPreCheck(t) },
103101
Steps: []resource.TestStep{
104102
{
105103
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -142,8 +140,7 @@ func TestAccVpcConnect_GCP_Basic(t *testing.T) {
142140
)
143141

144142
cloudamqpResourceTest(t, resource.TestCase{
145-
PreCheck: func() { testAccPreCheck(t) },
146-
ProviderFactories: testAccProviderFactory,
143+
PreCheck: func() { testAccPreCheck(t) },
147144
Steps: []resource.TestStep{
148145
{
149146
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_vpc_gcp_peering_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func TestAccVpcGcpPeering_Basic(t *testing.T) {
3333
)
3434

3535
cloudamqpResourceTest(t, resource.TestCase{
36-
PreCheck: func() { testAccPreCheck(t) },
37-
ProviderFactories: testAccProviderFactory,
36+
PreCheck: func() { testAccPreCheck(t) },
3837
Steps: []resource.TestStep{
3938
{
4039
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_vpc_peering_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func TestAccVpcPeering_Basic(t *testing.T) {
2222

2323
cloudamqpResourceTest(t, resource.TestCase{
2424
PreCheck: func() { testAccPreCheck(t) },
25-
ProviderFactories: testAccProviderFactory,
2625
PreventPostDestroyRefresh: true,
2726
Steps: []resource.TestStep{
2827
{

cloudamqp/resource_cloudamqp_webhook_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ func TestAccWebhook_Basic(t *testing.T) {
3737
)
3838

3939
cloudamqpResourceTest(t, resource.TestCase{
40-
PreCheck: func() { testAccPreCheck(t) },
41-
ProviderFactories: testAccProviderFactory,
40+
PreCheck: func() { testAccPreCheck(t) },
4241
Steps: []resource.TestStep{
4342
{
4443
Config: configuration.GetTemplatedConfig(t, fileNames, params),

go.mod

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ toolchain go1.23.0
66

77
require (
88
github.com/dghubble/sling v1.4.2
9+
github.com/hashicorp/terraform-plugin-go v0.26.0
10+
github.com/hashicorp/terraform-plugin-mux v0.18.0
911
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
1012
github.com/tidwall/gjson v1.18.0
1113
github.com/tidwall/sjson v1.2.5
@@ -36,9 +38,8 @@ require (
3638
github.com/hashicorp/logutils v1.0.0 // indirect
3739
github.com/hashicorp/terraform-exec v0.21.0 // indirect
3840
github.com/hashicorp/terraform-json v0.23.0 // indirect
39-
github.com/hashicorp/terraform-plugin-go v0.25.0 // indirect
4041
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
41-
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
42+
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
4243
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
4344
github.com/hashicorp/yamux v0.1.1 // indirect
4445
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -55,16 +56,16 @@ require (
5556
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
5657
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
5758
github.com/zclconf/go-cty v1.15.0 // indirect
58-
golang.org/x/crypto v0.31.0 // indirect
59+
golang.org/x/crypto v0.32.0 // indirect
5960
golang.org/x/mod v0.21.0 // indirect
60-
golang.org/x/net v0.33.0 // indirect
61+
golang.org/x/net v0.34.0 // indirect
6162
golang.org/x/sync v0.10.0 // indirect
62-
golang.org/x/sys v0.28.0 // indirect
63+
golang.org/x/sys v0.29.0 // indirect
6364
golang.org/x/text v0.21.0 // indirect
6465
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
6566
google.golang.org/appengine v1.6.8 // indirect
66-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
67-
google.golang.org/grpc v1.67.1 // indirect
68-
google.golang.org/protobuf v1.35.1 // indirect
67+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
68+
google.golang.org/grpc v1.69.4 // indirect
69+
google.golang.org/protobuf v1.36.3 // indirect
6970
gopkg.in/yaml.v3 v3.0.1 // indirect
7071
)

0 commit comments

Comments
 (0)