Skip to content

Commit

Permalink
Upgrade Terraform SDK to v2 (#21)
Browse files Browse the repository at this point in the history
* Upgrade Terraform SDK to v2

* fixup! Upgrade Terraform SDK to v2

* Rename Makefile
  • Loading branch information
cyrilgdn authored Sep 24, 2021
1 parent b68b21e commit 5591931
Show file tree
Hide file tree
Showing 37 changed files with 495 additions and 186 deletions.
File renamed without changes.
66 changes: 64 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,70 @@
module github.com/terraform-providers/terraform-provider-rabbitmq

require (
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0
github.com/michaelklishin/rabbit-hole/v2 v2.10.0
)

go 1.15
require (
cloud.google.com/go v0.61.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go v1.25.3 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-getter v1.5.3 // indirect
github.com/hashicorp/go-hclog v0.15.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.3.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.14.0 // indirect
github.com/hashicorp/terraform-json v0.12.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.4.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.4 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.8.4 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.29.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.32.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
)

go 1.17
474 changes: 361 additions & 113 deletions go.sum

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package main

import (
"github.com/hashicorp/terraform-plugin-sdk/plugin"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/terraform-providers/terraform-provider-rabbitmq/rabbitmq"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: rabbitmq.Provider})
ProviderFunc: rabbitmq.Provider,
})
}
2 changes: 1 addition & 1 deletion rabbitmq/import_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccBinding_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccExchange_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_federation_upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccFederationUpstream_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccPermissions_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccPolicy_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccQueue_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_shovel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccShovel_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_topic_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccTopicPermissions_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rabbitmq
import (
"testing"

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

func TestAccUser_importBasic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/import_vhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rabbitmq
import (
"testing"

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

func TestAccVhost_importBasic(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions rabbitmq/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func Provider() terraform.ResourceProvider {
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"endpoint": {
Expand Down
13 changes: 6 additions & 7 deletions rabbitmq/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"os"
"testing"

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

// To run these acceptance tests, you will need access to a RabbitMQ server
Expand All @@ -17,24 +16,24 @@ import (
// You can run the tests like this:
// make testacc TEST=./builtin/providers/rabbitmq

var testAccProviders map[string]terraform.ResourceProvider
var testAccProviders map[string]*schema.Provider
var testAccProvider *schema.Provider

func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
testAccProvider = Provider()
testAccProviders = map[string]*schema.Provider{
"rabbitmq": testAccProvider,
}
}

func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
if err := Provider().InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}

func TestProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = Provider()
var _ *schema.Provider = Provider()
}

func testAccPreCheck(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions rabbitmq/resource_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"net/url"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/structure"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
rabbithole "github.com/michaelklishin/rabbit-hole/v2"
)

Expand All @@ -19,7 +19,7 @@ func resourceBinding() *schema.Resource {
Read: ReadBinding,
Delete: DeleteBinding,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -68,7 +68,7 @@ func resourceBinding() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.ValidateJsonString,
ValidateFunc: validation.StringIsJSON,
ConflictsWith: []string{"arguments"},
DiffSuppressFunc: structure.SuppressJsonDiff,
},
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccBinding_basic(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func resourceExchange() *schema.Resource {
Expand All @@ -16,7 +16,7 @@ func resourceExchange() *schema.Resource {
Read: ReadExchange,
Delete: DeleteExchange,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccExchange(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions rabbitmq/resource_federation_upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
rabbithole "github.com/michaelklishin/rabbit-hole/v2"
)

Expand All @@ -16,7 +16,7 @@ func resourceFederationUpstream() *schema.Resource {
Update: UpdateFederationUpstream,
Delete: DeleteFederationUpstream,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down
6 changes: 3 additions & 3 deletions rabbitmq/resource_federation_upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
rabbithole "github.com/michaelklishin/rabbit-hole/v2"
)

Expand Down Expand Up @@ -106,7 +106,7 @@ func TestAccFederationUpstream_validation(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccFederationUpstream_validation(),
ExpectError: regexp.MustCompile("^config is invalid"),
ExpectError: regexp.MustCompile("expected definition.0.ack_mode to be one of"),
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func resourcePermissions() *schema.Resource {
Expand All @@ -17,7 +17,7 @@ func resourcePermissions() *schema.Resource {
Read: ReadPermissions,
Delete: DeletePermissions,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func TestAccPermissions(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions rabbitmq/resource_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

rabbithole "github.com/michaelklishin/rabbit-hole/v2"

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

func resourcePolicy() *schema.Resource {
Expand All @@ -18,7 +18,7 @@ func resourcePolicy() *schema.Resource {
Read: ReadPolicy,
Delete: DeletePolicy,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down
Loading

0 comments on commit 5591931

Please sign in to comment.