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

Upgrade Terraform SDK to v2.0.1 #129

Merged
merged 2 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/hashicorp/go-retryablehttp v0.6.6
github.com/hashicorp/terraform-plugin-sdk v1.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.1
github.com/selectel/domains-go v0.2.0
github.com/selectel/go-selvpcclient v1.12.0
github.com/selectel/mks-go v0.5.0
Expand Down
317 changes: 266 additions & 51 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

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

Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_domains_domain_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"fmt"
"testing"

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

func TestAccDomainsDomainV1ImportBasic(t *testing.T) {
resourceName := "selectel_domains_domain_v1.domain_tf_acc_test_1"
testDomainName := fmt.Sprintf("%s.xyz", acctest.RandomWithPrefix("tf-acc"))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDomainsV1DomainDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckDomainsV1DomainDestroy,
Steps: []resource.TestStep{
{
Config: testAccDomainsDomainV1Basic(testDomainName),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_domains_record_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

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

func TestAccDomainsRecordV1ImportBasic(t *testing.T) {
Expand All @@ -14,9 +14,9 @@ func TestAccDomainsRecordV1ImportBasic(t *testing.T) {
testRecordName := fmt.Sprintf("a.%s", testDomainName)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDomainsV1DomainDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckDomainsV1DomainDestroy,
Steps: []resource.TestStep{
{
Config: testAccDomainsRecordV1BasicSingle(testDomainName, testRecordName),
Expand Down
16 changes: 8 additions & 8 deletions selectel/import_selectel_mks_cluster_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package selectel
import (
"testing"

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

func TestAccMKSClusterV1ImportBasic(t *testing.T) {
Expand All @@ -14,9 +14,9 @@ func TestAccMKSClusterV1ImportBasic(t *testing.T) {
kubeVersion := testAccMKSClusterV1GetDefaultKubeVersion(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccMKSClusterV1Basic(projectName, clusterName, kubeVersion),
Expand All @@ -38,9 +38,9 @@ func TestAccMKSClusterV1ImportZonal(t *testing.T) {
kubeVersion := testAccMKSClusterV1GetDefaultKubeVersion(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccMKSClusterV1Zonal(projectName, clusterName, kubeVersion),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_mks_nodegroup_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package selectel
import (
"testing"

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

func TestAccMKSNodegroupV1ImportBasic(t *testing.T) {
Expand All @@ -14,9 +14,9 @@ func TestAccMKSNodegroupV1ImportBasic(t *testing.T) {
kubeVersion := testAccMKSClusterV1GetDefaultKubeVersion(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccMKSNodegroupV1Basic(projectName, clusterName, kubeVersion),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_floatingip_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package selectel
import (
"testing"

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

func TestAccVPCV2FloatingIPImportBasic(t *testing.T) {
resourceName := "selectel_vpc_floatingip_v2.floatingip_tf_acc_test_1"
projectName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2FloatingIPDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2FloatingIPDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2FloatingIPBasic(projectName),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_keypair_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package selectel
import (
"testing"

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

func TestAccVPCV2KeypairImportBasic(t *testing.T) {
Expand All @@ -15,9 +15,9 @@ func TestAccVPCV2KeypairImportBasic(t *testing.T) {
userPassword := acctest.RandString(8)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2KeypairDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2KeypairDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2KeypairBasic(userName, userPassword, keypairName, publicKey),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_license_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package selectel
import (
"testing"

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

func TestAccVPCV2LicenseImportBasic(t *testing.T) {
resourceName := "selectel_vpc_license_v2.license_tf_acc_test_1"
projectName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2LicenseDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2LicenseDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2LicenseBasic(projectName),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_project_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package selectel
import (
"testing"

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

func TestAccVPCV2ProjectImportBasic(t *testing.T) {
resourceName := "selectel_vpc_project_v2.project_tf_acc_test_1"
projectName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2ProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2ProjectBasic(projectName),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_role_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package selectel
import (
"testing"

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

func TestAccVPCV2RoleImportBasic(t *testing.T) {
Expand All @@ -14,9 +14,9 @@ func TestAccVPCV2RoleImportBasic(t *testing.T) {
userPassword := acctest.RandString(8)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2RoleDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2RoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2RoleBasic(projectName, userName, userPassword),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_subnet_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package selectel
import (
"testing"

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

func TestAccVPCV2SubnetImportBasic(t *testing.T) {
resourceName := "selectel_vpc_subnet_v2.subnet_tf_acc_test_1"
projectName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2SubnetDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2SubnetDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2SubnetBasic(projectName),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_user_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package selectel
import (
"testing"

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

func TestAccVPCV2UserImportBasic(t *testing.T) {
Expand All @@ -13,9 +13,9 @@ func TestAccVPCV2UserImportBasic(t *testing.T) {
userPassword := acctest.RandString(8)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2UserDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2UserDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2UserBasic(userName, userPassword),
Expand Down
10 changes: 5 additions & 5 deletions selectel/import_selectel_vpc_vrrp_subnet_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package selectel
import (
"testing"

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

func TestAccVPCV2VRRPSubnetImportBasic(t *testing.T) {
resourceName := "selectel_vpc_vrrp_subnet_v2.vrrp_subnet_tf_acc_test_1"
projectName := acctest.RandomWithPrefix("tf-acc")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccSelectelPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVPCV2VRRPSubnetDestroy,
PreCheck: func() { testAccSelectelPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckVPCV2VRRPSubnetDestroy,
Steps: []resource.TestStep{
{
Config: testAccVPCV2VRRPSubnetBasic(projectName),
Expand Down
25 changes: 25 additions & 0 deletions selectel/internal/hashcode/hashcode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package hashcode

import (
"hash/crc32"
)

// String hashes a string to a unique hashcode.
//
// This implementation is copied from v1 Terraform SDK since it was removed
// from v2 SDK.
//
// crc32 returns a uint32, but for our use we need
// and non negative integer. Here we cast to an integer
// and invert it if the result is negative.
func String(s string) int {
v := int(crc32.ChecksumIEEE([]byte(s)))
if v >= 0 {
return v
}
if -v >= 0 {
return -v
}
// v == MinInt
return 0
}
24 changes: 24 additions & 0 deletions selectel/internal/hashcode/hashcode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package hashcode

import "testing"

func TestString(t *testing.T) {
v := "hello, world"
expected := String(v)
for i := 0; i < 100; i++ {
actual := String(v)
if actual != expected {
t.Fatalf("bad: %#v\n\t%#v", actual, expected)
}
}
}

func TestString_positiveIndex(t *testing.T) {
// "2338615298" hashes to uint32(2147483648) which is math.MinInt32
ips := []string{"192.168.1.3", "192.168.1.5", "2338615298"}
for _, ip := range ips {
if index := String(ip); index < 0 {
t.Fatalf("Bad Index %#v for ip %s", index, ip)
}
}
}
Loading