Skip to content

Commit

Permalink
Upgrade Terraform SDK to v2.6.1 (#642)
Browse files Browse the repository at this point in the history
* Update terraform-plugin-sdk to v2.6.1.

* Remove internall setutil in favor of SDK version.

* Use stable IDs for 'datalist' data sources.

* Fix TestAccDataSourceDigitalOceanProjects_Basic

* Update deprecated values in Droplet tests.

* Fix CDN tests. TTL is an enum now.
  • Loading branch information
andrewsomething authored May 28, 2021
1 parent 0690486 commit f017e00
Show file tree
Hide file tree
Showing 1,088 changed files with 86,456 additions and 82,808 deletions.
10 changes: 4 additions & 6 deletions digitalocean/datasource_digitalocean_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"regexp"
"testing"

"github.com/digitalocean/terraform-provider-digitalocean/internal/setutil"

"github.com/digitalocean/godo"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down Expand Up @@ -43,7 +41,7 @@ data "digitalocean_loadbalancer" "foobar" {
"data.digitalocean_loadbalancer.foobar", "size", "lb-small"),
resource.TestCheckResourceAttr(
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"data.digitalocean_loadbalancer.foobar",
"forwarding_rule.*",
map[string]string{
Expand Down Expand Up @@ -105,7 +103,7 @@ data "digitalocean_loadbalancer" "foobar" {
"data.digitalocean_loadbalancer.foobar", "size", "lb-large"),
resource.TestCheckResourceAttr(
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"data.digitalocean_loadbalancer.foobar",
"forwarding_rule.*",
map[string]string{
Expand Down Expand Up @@ -166,7 +164,7 @@ data "digitalocean_loadbalancer" "foobar" {
"data.digitalocean_loadbalancer.foobar", "size", "lb-small"),
resource.TestCheckResourceAttr(
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.#", "2"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"data.digitalocean_loadbalancer.foobar",
"forwarding_rule.*",
map[string]string{
Expand All @@ -176,7 +174,7 @@ data "digitalocean_loadbalancer" "foobar" {
"target_protocol": "https",
},
),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"data.digitalocean_loadbalancer.foobar",
"forwarding_rule.*",
map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion digitalocean/datasource_digitalocean_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ data "digitalocean_projects" "both" {
Config: resourcesConfig,
},
{
Config: datasourcesConfig,
Config: resourcesConfig + datasourcesConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.digitalocean_projects.prod", "projects.#", "1"),
resource.TestCheckResourceAttr("data.digitalocean_projects.prod", "projects.0.name", prodProjectName),
Expand Down
20 changes: 9 additions & 11 deletions digitalocean/resource_digitalocean_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"strings"
"testing"

"github.com/digitalocean/terraform-provider-digitalocean/internal/setutil"

"github.com/digitalocean/godo"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down Expand Up @@ -327,7 +325,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
"digitalocean_app.foobar", "spec.0.name", appName),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.service.0.env.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.service.0.env.*",
map[string]string{
Expand All @@ -338,7 +336,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.env.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.env.*",
map[string]string{
Expand All @@ -357,7 +355,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
"digitalocean_app.foobar", "spec.0.name", appName),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.service.0.env.#", "2"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.service.0.env.*",
map[string]string{
Expand All @@ -366,7 +364,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
"scope": "RUN_AND_BUILD_TIME",
},
),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.service.0.env.*",
map[string]string{
Expand All @@ -377,7 +375,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.env.#", "2"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.env.*",
map[string]string{
Expand All @@ -386,7 +384,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
"scope": "RUN_AND_BUILD_TIME",
},
),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.env.*",
map[string]string{
Expand All @@ -405,7 +403,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
"digitalocean_app.foobar", "spec.0.name", appName),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.service.0.env.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.service.0.env.*",
map[string]string{
Expand All @@ -416,7 +414,7 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
),
resource.TestCheckResourceAttr(
"digitalocean_app.foobar", "spec.0.env.#", "1"),
setutil.TestCheckTypeSetElemNestedAttrs(
resource.TestCheckTypeSetElemNestedAttrs(
"digitalocean_app.foobar",
"spec.0.env.*",
map[string]string{
Expand Down Expand Up @@ -735,7 +733,7 @@ resource "digitalocean_app" "foobar" {
repo_clone_url = "https://github.com/digitalocean/sample-golang.git"
branch = "main"
}
internal_ports = [ 5000 ]
}
}
Expand Down
10 changes: 5 additions & 5 deletions digitalocean/resource_digitalocean_cdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func TestAccDigitalOceanCDN_Create(t *testing.T) {
func TestAccDigitalOceanCDN_Create_with_TTL(t *testing.T) {

bucketName := generateBucketName()
ttl := 1800
ttl := 600
cdnCreateConfig := fmt.Sprintf(testAccCheckDigitalOceanCDNConfig_Create_with_TTL, bucketName, ttl)

expectedOrigin := bucketName + originSuffix
expectedTTL := "1800"
expectedTTL := "600"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -68,13 +68,13 @@ func TestAccDigitalOceanCDN_Create_with_TTL(t *testing.T) {
func TestAccDigitalOceanCDN_Create_and_Update(t *testing.T) {

bucketName := generateBucketName()
ttl := 1800
ttl := 600

cdnCreateConfig := fmt.Sprintf(testAccCheckDigitalOceanCDNConfig_Create, bucketName)
cdnUpdateConfig := fmt.Sprintf(testAccCheckDigitalOceanCDNConfig_Create_with_TTL, bucketName, ttl)

expectedOrigin := bucketName + originSuffix
expectedTTL := "1800"
expectedTTL := "600"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -279,7 +279,7 @@ resource "digitalocean_cdn" "space_cdn" {
]
origin = digitalocean_spaces_bucket.space.bucket_domain_name
ttl = 2400
ttl = 600
certificate_name = digitalocean_certificate.spaces_cert.name
custom_domain = "foo.%s"
}`, domain, domain, certName, spaceName, certName, domain, domain)
Expand Down
15 changes: 7 additions & 8 deletions digitalocean/resource_digitalocean_custom_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strconv"
"testing"

"github.com/digitalocean/terraform-provider-digitalocean/internal/setutil"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down Expand Up @@ -67,25 +66,25 @@ func TestAccDigitalOceanCustomImageMultiRegion(t *testing.T) {
Config: testAccCheckDigitalOceanCustomImageConfig(rString, rString, regions, "Unknown"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s-name", rString)),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
),
},
{
Config: testAccCheckDigitalOceanCustomImageConfig(rString, rString, regionsUpdated, "Unknown"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s-name", rString)),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "tor1"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "tor1"),
),
},
{
Config: testAccCheckDigitalOceanCustomImageConfig(rString, rString, regions, "Unknown"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "name", fmt.Sprintf("%s-name", rString)),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
setutil.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc2"),
resource.TestCheckTypeSetElemAttr(name, "regions.*", "nyc3"),
),
},
},
Expand Down
Loading

0 comments on commit f017e00

Please sign in to comment.