Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to sdk v2 #261

Merged
merged 8 commits into from
May 14, 2024
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAccount() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_account_vpcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAccountVpcs() *schema.Resource {
Expand Down
12 changes: 6 additions & 6 deletions cloudamqp/data_source_cloudamqp_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"strconv"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAlarm() *schema.Resource {
return &schema.Resource{
Read: dataSourceAlarmRead,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Expand All @@ -26,10 +26,10 @@ func dataSourceAlarm() *schema.Resource {
Description: "Alarm identifier",
},
"type": {
Type: schema.TypeString,
Optional: true,
Description: "Type of the alarm",
ValidateFunc: validateAlarmType(),
Type: schema.TypeString,
Optional: true,
Description: "Type of the alarm",
ValidateDiagFunc: validateAlarmType(),
},
"enabled": {
Type: schema.TypeBool,
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudamqp

import (
"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"fmt"
)
Expand Down
4 changes: 2 additions & 2 deletions cloudamqp/data_source_cloudamqp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"strconv"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceInstance() *schema.Resource {
return &schema.Resource{
Read: dataSourceInstanceRead,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceNodes() *schema.Resource {
Expand Down
4 changes: 2 additions & 2 deletions cloudamqp/data_source_cloudamqp_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"strconv"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceNotification() *schema.Resource {
return &schema.Resource{
Read: dataSourceNotificationRead,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourcePlugins() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_plugins_community.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourcePluginsCommunity() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_upgradable_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceUpgradableVersions() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_vpc_gcp_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceVpcGcpInfo() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/data_source_cloudamqp_vpc_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceVpcInfo() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion cloudamqp/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var version string
Expand Down
15 changes: 6 additions & 9 deletions cloudamqp/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ import (
"testing"

"github.com/cloudamqp/terraform-provider-cloudamqp/cloudamqp/vcr-testing/sanitizer"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/tidwall/gjson"
"gopkg.in/dnaeon/go-vcr.v3/cassette"
"gopkg.in/dnaeon/go-vcr.v3/recorder"
)

var (
testAccProvider *schema.Provider
testAccProviders map[string]terraform.ResourceProvider
testAccProviderFactory map[string]func() (*schema.Provider, error)

mode = recorder.ModeReplayOnly
)
Expand Down Expand Up @@ -157,11 +155,10 @@ func cloudamqpResourceTest(t *testing.T, c resource.TestCase) {
return req.URL.Path == "/login"
})

testAccProvider = Provider("1.0", rec.GetDefaultClient())
testAccProviders = map[string]terraform.ResourceProvider{
"cloudamqp": testAccProvider,
testAccProviderFactory = map[string]func() (*schema.Provider, error){
"cloudamqp": func() (*schema.Provider, error) { return Provider("1.0", rec.GetDefaultClient()), nil },
}
c.Providers = testAccProviders
c.ProviderFactories = testAccProviderFactory

resource.Test(t, c)
}
Expand Down
20 changes: 10 additions & 10 deletions cloudamqp/resource_cloudamqp_account_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/84codes/go-api/api"
"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"
)

func resourceAccountAction() *schema.Resource {
Expand All @@ -22,11 +22,11 @@ func resourceAccountAction() *schema.Resource {
Description: "Instance identifier",
},
"action": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The action to perform on the node",
ValidateFunc: validateAccountAction(),
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "The action to perform on the node",
ValidateDiagFunc: validateAccountAction(),
},
},
}
Expand Down Expand Up @@ -62,9 +62,9 @@ func resourceAccountActionRemove(d *schema.ResourceData, meta interface{}) error
return nil
}

func validateAccountAction() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
func validateAccountAction() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{
"rotate-password",
"rotate-apikey",
}, true)
}, true))
}
48 changes: 24 additions & 24 deletions cloudamqp/resource_cloudamqp_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"

"github.com/84codes/go-api/api"
"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"
)

func resourceAlarm() *schema.Resource {
Expand All @@ -19,7 +19,7 @@ func resourceAlarm() *schema.Resource {
Update: resourceAlarmUpdate,
Delete: resourceAlarmDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Expand All @@ -29,10 +29,10 @@ func resourceAlarm() *schema.Resource {
Description: "Instance identifier",
},
"type": {
Type: schema.TypeString,
Required: true,
Description: "Type of the alarm, valid options are: cpu, memory, disk_usage, queue_length, connection_count, consumers_count, net_split",
ValidateFunc: validateAlarmType(),
Type: schema.TypeString,
Required: true,
Description: "Type of the alarm, valid options are: cpu, memory, disk_usage, queue_length, connection_count, consumers_count, net_split",
ValidateDiagFunc: validateAlarmType(),
},
"enabled": {
Type: schema.TypeBool,
Expand All @@ -51,10 +51,10 @@ func resourceAlarm() *schema.Resource {
Description: "What value to trigger the alarm for",
},
"value_calculation": {
Type: schema.TypeString,
Optional: true,
Description: "Disk value threshold calculation. Fixed or percentage of disk space remaining",
ValidateFunc: validateValueCalculation(),
Type: schema.TypeString,
Optional: true,
Description: "Disk value threshold calculation. Fixed or percentage of disk space remaining",
ValidateDiagFunc: validateValueCalculation(),
},
"time_threshold": {
Type: schema.TypeInt,
Expand All @@ -72,10 +72,10 @@ func resourceAlarm() *schema.Resource {
Description: "Regex for which queues to check",
},
"message_type": {
Type: schema.TypeString,
Optional: true,
Description: "Message types (total, unacked, ready) of the queue to trigger the alarm",
ValidateFunc: validateMessageType(),
Type: schema.TypeString,
Optional: true,
Description: "Message types (total, unacked, ready) of the queue to trigger the alarm",
ValidateDiagFunc: validateMessageType(),
},
"recipients": {
Type: schema.TypeList,
Expand Down Expand Up @@ -199,8 +199,8 @@ func resourceAlarmDelete(d *schema.ResourceData, meta interface{}) error {
return api.DeleteAlarm(d.Get("instance_id").(int), params)
}

func validateAlarmType() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
func validateAlarmType() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{
"cpu",
"memory",
"disk",
Expand All @@ -212,7 +212,7 @@ func validateAlarmType() schema.SchemaValidateFunc {
"ssh",
"notice",
"server_unreachable",
}, true)
}, true))
}

func validateAlarmSchemaAttribute(key string) bool {
Expand All @@ -232,19 +232,19 @@ func validateAlarmSchemaAttribute(key string) bool {
return false
}

func validateMessageType() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
func validateMessageType() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{
"total",
"unacked",
"ready",
}, true)
}, true))
}

func validateValueCalculation() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
func validateValueCalculation() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice([]string{
"fixed",
"percentage",
}, true)
}, true))
}

func alarmAttributeKeys() []string {
Expand Down
8 changes: 4 additions & 4 deletions cloudamqp/resource_cloudamqp_alarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

"github.com/cloudamqp/terraform-provider-cloudamqp/cloudamqp/vcr-testing/configuration"
"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"
)

// TestAccAlarm_Basic: Create CPU alarm, import and change values.
Expand Down Expand Up @@ -56,8 +56,8 @@ func TestAccAlarm_Basic(t *testing.T) {
)

cloudamqpResourceTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactory,
Steps: []resource.TestStep{
{
Config: configuration.GetTemplatedConfig(t, fileNames, params),
Expand Down
4 changes: 2 additions & 2 deletions cloudamqp/resource_cloudamqp_aws_eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/84codes/go-api/api"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func resourceAwsEventBridge() *schema.Resource {
Expand All @@ -16,7 +16,7 @@ func resourceAwsEventBridge() *schema.Resource {
Read: resourceAwsEventBridgeRead,
Delete: resourceAwsEventBridgeDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"instance_id": {
Expand Down
Loading