upgrade provider to use terraform-plugin-sdk v2 (#492)
* upgrade terraform-plugin-sdk and `go mod vendor` * Update digitalocean/datasource_digitalocean_image_test.go Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com> * Update digitalocean/datasource_digitalocean_kubernetes_cluster_test.go Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com> * Update digitalocean/datasource_digitalocean_vpc_test.go Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com> * Update digitalocean/datasource_digitalocean_vpc_test.go Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com> * go fmt * fix droplet_id to be of the right type * fix digitalocean_project resource * fix creation order in digitalocean_certificate test * fix digitalocean_container_registry data source tes * Port new changes to v2. * Port all tests to resource.ParallelTest * Fix KubernetesProviderInteroperability test. * Fix TestAccDigitalOceanKubernetesCluster_UpgradeVersion * Fix firewall panic s/create_at/created_at/ * Fix TestAccDigitalOceanDroplet_Basic: Droplets now have private networking by default. * Fix TestAccDataSourceDigitalOceanDomain_Basic * Fix TestAccDataSourceDigitalOceanDropletSnapshot tests. * Fix TestAccDataSourceDigitalOceanSSHKey_Basic * Fix TestAccDataSourceDigitalOceanVolumeSnapshot tests. * Fix TestAccDataSourceDigitalOceanVolume tests. * Fix TestAccDataSourceDigitalOceanRecord_Basic * Fix TestAccDataSourceDigitalOceanProject_NonDefaultProject * Fix TestAccDigitalOceanImage_PublicSlug * Fix TestAccDataSourceDigitalOceanImages_Basic via bug in imageSchema() * go mod tidy * Fix TestAccDataSourceDigitalOceanDroplet tests. * Fix TestAccDataSourceDigitalOceanVPC_ByName * Fix TestAccDataSourceDigitalOceanTag_Basic * Fix TestAccDataSourceDigitalOceanTags_Basic * Ensure versions are set in DBaaS tests. * Fix TestAccDataSourceDigitalOceanApp_Basic * Fix non-set related issues with TestAccDataSourceDigitalOceanLoadBalancer tests. * Fix TestAccDataSourceDigitalOceanKubernetesCluster_Basic * Remove testAccDigitalOceanKubernetesConfigWithEmptyNodePool: Empty node pools are no longer supported. * Fix TestAccDigitalOceanProject_WithManyResources. * Fix TestAccDigitalOceanProject_UpdateFromDropletToSpacesResource * vendor set helpers from AWS provider * Fix TestAccDigitalOceanFloatingIP_Droplet. * Fix CDN panic. * fix TestAccDigitalOceanSpacesBucket_LifecycleBasic using setutil helpers * vendor set helpers from AWS provider * fix TestAccDigitalOceanSpacesBucket_LifecycleBasic using setutil helpers * Fix load balancer tests using setutil helpers. * Fix K8s tests using setutil helpers. * Fix TestAccDigitalOceanApp_Envs using setutil helpers. * Fix TestAccDigitalOceanSpacesBucket_LifecycleExpireMarkerOnly using setutil helpers. * Fix TestAccDigitalOceanFloatingIPAssignment_createBeforeDestroy * fix remaining TypeSet tests using setutil * Registry test can not run in parallel. One per account. * Fix TestAccDigitalOceanProject_UpdateWithDropletResource * Fix replica tests. * go mod tidy Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com> Co-authored-by: Andrew Starr-Bochicchio <a.starr.b@gmail.com>
This commit is contained in:
parent
2ac71bf121
commit
f50c276f6e
|
@ -4,8 +4,8 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 appSpecSchema() map[string]*schema.Schema {
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanAccount() *schema.Resource {
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanAccount_Basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanAccountConfig_basic),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package digitalocean
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanApp() *schema.Resource {
|
||||
|
@ -15,7 +15,6 @@ func dataSourceDigitalOceanApp() *schema.Resource {
|
|||
"spec": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
MaxItems: 1,
|
||||
Description: "A DigitalOcean App Platform Spec",
|
||||
Elem: &schema.Resource{
|
||||
Schema: appSpecSchema(),
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanApp_Basic(t *testing.T) {
|
||||
|
@ -45,7 +45,7 @@ func TestAccDataSourceDigitalOceanApp_Basic(t *testing.T) {
|
|||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_app.foobar", "spec.0.service.0.instance_count", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_app.foobar", "spec.0.service.0.instance_size_slug", "professional-xs"),
|
||||
"data.digitalocean_app.foobar", "spec.0.service.0.instance_size_slug", "basic-xxs"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_app.foobar", "spec.0.service.0.routes.0.path", "/"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanCertificate() *schema.Resource {
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanCertificate_Basic(t *testing.T) {
|
||||
|
@ -16,12 +16,15 @@ func TestAccDataSourceDigitalOceanCertificate_Basic(t *testing.T) {
|
|||
|
||||
privateKeyMaterial, leafCertMaterial, certChainMaterial := generateTestCertMaterial(t)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanCertificateConfig_basic(name, privateKeyMaterial, leafCertMaterial, certChainMaterial),
|
||||
Config: testAccCheckDataSourceDigitalOceanCertificateConfig_basic(name, privateKeyMaterial, leafCertMaterial, certChainMaterial, false),
|
||||
},
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanCertificateConfig_basic(name, privateKeyMaterial, leafCertMaterial, certChainMaterial, true),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanCertificateExists("data.digitalocean_certificate.foobar", &certificate),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -61,8 +64,11 @@ func testAccCheckDataSourceDigitalOceanCertificateExists(n string, certificate *
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanCertificateConfig_basic(name, privateKeyMaterial, leafCert, certChain string) string {
|
||||
return fmt.Sprintf(`
|
||||
func testAccCheckDataSourceDigitalOceanCertificateConfig_basic(
|
||||
name, privateKeyMaterial, leafCert, certChain string,
|
||||
includeDataSource bool,
|
||||
) string {
|
||||
config := fmt.Sprintf(`
|
||||
resource "digitalocean_certificate" "foo" {
|
||||
name = "%s"
|
||||
private_key = <<EOF
|
||||
|
@ -75,9 +81,15 @@ EOF
|
|||
%s
|
||||
EOF
|
||||
}
|
||||
|
||||
data "digitalocean_certificate" "foobar" {
|
||||
name = "${digitalocean_certificate.foo.name}"
|
||||
}
|
||||
`, name, privateKeyMaterial, leafCert, certChain)
|
||||
|
||||
if includeDataSource {
|
||||
config += `
|
||||
data "digitalocean_certificate" "foobar" {
|
||||
name = digitalocean_certificate.foo.name
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
const RegistryHostname = "registry.digitalocean.com"
|
||||
|
|
|
@ -6,21 +6,36 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanContainerRegistry_Basic(t *testing.T) {
|
||||
var reg godo.Registry
|
||||
regName := fmt.Sprintf("foo-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_container_registry" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
`, regName)
|
||||
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_container_registry" "foobar" {
|
||||
name = digitalocean_container_registry.foo.name
|
||||
}
|
||||
`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanContainerRegistryConfig_basic, regName),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanContainerRegistryExists("data.digitalocean_container_registry.foobar", ®),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -60,12 +75,3 @@ func testAccCheckDataSourceDigitalOceanContainerRegistryExists(n string, reg *go
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanContainerRegistryConfig_basic = `
|
||||
resource "digitalocean_container_registry" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
|
||||
data "digitalocean_container_registry" "foobar" {
|
||||
name = "${digitalocean_container_registry.foo.name}"
|
||||
}`
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanDatabaseCluster() *schema.Resource {
|
||||
|
@ -48,7 +48,6 @@ func dataSourceDigitalOceanDatabaseCluster() *schema.Resource {
|
|||
"maintenance_window": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
MinItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"day": {
|
||||
|
|
|
@ -5,20 +5,20 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 TestAccDataSourceDigitalOceanDatabaseCluster_Basic(t *testing.T) {
|
||||
var database godo.Database
|
||||
databaseName := fmt.Sprintf("foobar-test-terraform-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanDatabaseClusterConfigBasic, databaseName),
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"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 dataSourceDigitalOceanDomain() *schema.Resource {
|
||||
|
|
|
@ -6,23 +6,37 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanDomain_Basic(t *testing.T) {
|
||||
var domain godo.Domain
|
||||
domainName := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10))
|
||||
|
||||
expectedURN := fmt.Sprintf("do:domain:%s", domainName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_domain" "foo" {
|
||||
name = "%s"
|
||||
ip_address = "192.168.0.10"
|
||||
}
|
||||
`, domainName)
|
||||
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_domain" "foobar" {
|
||||
name = "${digitalocean_domain.foo.name}"
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanDomainConfig_basic, domainName),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanDomainExists("data.digitalocean_domain.foobar", &domain),
|
||||
testAccCheckDataSourceDigitalOceanDomainAttributes(&domain, domainName),
|
||||
|
@ -76,13 +90,3 @@ func testAccCheckDataSourceDigitalOceanDomainExists(n string, domain *godo.Domai
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanDomainConfig_basic = `
|
||||
resource "digitalocean_domain" "foo" {
|
||||
name = "%s"
|
||||
ip_address = "192.168.0.10"
|
||||
}
|
||||
|
||||
data "digitalocean_domain" "foobar" {
|
||||
name = "${digitalocean_domain.foo.name}"
|
||||
}`
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanDomains() *schema.Resource {
|
||||
|
|
|
@ -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 TestAccDataSourceDigitalOceanDomains_Basic(t *testing.T) {
|
||||
|
@ -31,9 +31,9 @@ data "digitalocean_domains" "result" {
|
|||
}
|
||||
`, name1)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: resourcesConfig,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanDroplet() *schema.Resource {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanDropletSnapshot() *schema.Resource {
|
||||
|
|
|
@ -6,25 +6,33 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanDropletSnapshot_basic(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_basic, testName, testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name = digitalocean_droplet_snapshot.foo.name
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_basic, rInt, rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanDropletSnapshotExists("data.digitalocean_droplet_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "20"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "25"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "regions.#", "1"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet_snapshot.foobar", "droplet_id"),
|
||||
),
|
||||
|
@ -35,18 +43,27 @@ func TestAccDataSourceDigitalOceanDropletSnapshot_basic(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanDropletSnapshot_regex(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_basic, testName, testName)
|
||||
dataSourceConfig := fmt.Sprintf(`
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name_regex = "^%s"
|
||||
}`, testName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_regex, rInt, rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanDropletSnapshotExists("data.digitalocean_droplet_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "20"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "25"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "regions.#", "1"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet_snapshot.foobar", "droplet_id"),
|
||||
),
|
||||
|
@ -57,18 +74,39 @@ func TestAccDataSourceDigitalOceanDropletSnapshot_regex(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanDropletSnapshot_region(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
nycResourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_basic, testName, testName)
|
||||
lonResourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_droplet" "bar" {
|
||||
region = "lon1"
|
||||
name = "%s"
|
||||
size = "s-1vcpu-1gb"
|
||||
image = "centos-7-x64"
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource "digitalocean_droplet_snapshot" "bar" {
|
||||
name = "%s-snapshot"
|
||||
droplet_id = "${digitalocean_droplet.bar.id}"
|
||||
}`, testName, testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
name = digitalocean_droplet_snapshot.bar.name
|
||||
region = "lon1"
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanDropletSnapshot_region, rInt, rInt, rInt, rInt),
|
||||
Config: nycResourceConfig + lonResourceConfig,
|
||||
},
|
||||
{
|
||||
Config: nycResourceConfig + lonResourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanDropletSnapshotExists("data.digitalocean_droplet_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "20"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "min_disk_size", "25"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_droplet_snapshot.foobar", "regions.#", "1"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet_snapshot.foobar", "droplet_id"),
|
||||
),
|
||||
|
@ -108,70 +146,14 @@ func testAccCheckDataSourceDigitalOceanDropletSnapshotExists(n string, snapshot
|
|||
|
||||
const testAccCheckDataSourceDigitalOceanDropletSnapshot_basic = `
|
||||
resource "digitalocean_droplet" "foo" {
|
||||
name = "foo-%d"
|
||||
size = "512mb"
|
||||
name = "%s"
|
||||
size = "s-1vcpu-1gb"
|
||||
image = "centos-7-x64"
|
||||
region = "nyc3"
|
||||
ipv6 = true
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
droplet_id = "${digitalocean_droplet.foo.id}"
|
||||
name = "%s-snapshot"
|
||||
droplet_id = digitalocean_droplet.foo.id
|
||||
}
|
||||
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name = "${digitalocean_droplet_snapshot.foo.name}"
|
||||
}`
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanDropletSnapshot_regex = `
|
||||
resource "digitalocean_droplet" "foo" {
|
||||
region = "nyc1"
|
||||
name = "foo-%d"
|
||||
size = "512mb"
|
||||
image = "centos-7-x64"
|
||||
ipv6 = true
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
droplet_id = "${digitalocean_droplet.foo.id}"
|
||||
}
|
||||
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name_regex = "^${digitalocean_droplet_snapshot.foo.name}"
|
||||
}`
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanDropletSnapshot_region = `
|
||||
resource "digitalocean_droplet" "foo" {
|
||||
region = "nyc1"
|
||||
name = "foo-nyc-%d"
|
||||
size = "512mb"
|
||||
image = "centos-7-x64"
|
||||
ipv6 = true
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet" "bar" {
|
||||
region = "lon1"
|
||||
name = "bar-lon-%d"
|
||||
size = "512mb"
|
||||
image = "centos-7-x64"
|
||||
ipv6 = true
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
droplet_id = "${digitalocean_droplet.foo.id}"
|
||||
}
|
||||
|
||||
resource "digitalocean_droplet_snapshot" "bar" {
|
||||
name = "snapshot-%d"
|
||||
droplet_id = "${digitalocean_droplet.bar.id}"
|
||||
}
|
||||
|
||||
data "digitalocean_droplet_snapshot" "foobar" {
|
||||
name = "${digitalocean_droplet_snapshot.bar.name}"
|
||||
region = "lon1"
|
||||
}`
|
||||
`
|
||||
|
|
|
@ -7,21 +7,29 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanDroplet_BasicByName(t *testing.T) {
|
||||
var droplet godo.Droplet
|
||||
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10))
|
||||
name := randomTestName()
|
||||
resourceConfig := testAccCheckDataSourceDigitalOceanDropletConfig_basicByName(name)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_droplet" "foobar" {
|
||||
name = digitalocean_droplet.foo.name
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanDropletConfig_basicByName(name),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanDropletExists("data.digitalocean_droplet.foobar", &droplet),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -47,9 +55,9 @@ func TestAccDataSourceDigitalOceanDroplet_BasicById(t *testing.T) {
|
|||
var droplet godo.Droplet
|
||||
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanDropletConfig_basicById(name),
|
||||
|
@ -64,7 +72,7 @@ func TestAccDataSourceDigitalOceanDroplet_BasicById(t *testing.T) {
|
|||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_droplet.foobar", "ipv6", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_droplet.foobar", "private_networking", "false"),
|
||||
"data.digitalocean_droplet.foobar", "private_networking", "true"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet.foobar", "urn"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet.foobar", "created_at"),
|
||||
),
|
||||
|
@ -78,9 +86,9 @@ func TestAccDataSourceDigitalOceanDroplet_BasicByTag(t *testing.T) {
|
|||
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10))
|
||||
tagName := fmt.Sprintf("tf-acc-test-tag-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanDropletConfig_basicWithTag(tagName, name),
|
||||
|
@ -101,7 +109,7 @@ func TestAccDataSourceDigitalOceanDroplet_BasicByTag(t *testing.T) {
|
|||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_droplet.foobar", "ipv6", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_droplet.foobar", "private_networking", "false"),
|
||||
"data.digitalocean_droplet.foobar", "private_networking", "true"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_droplet.foobar", "tags.#", "1"),
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_droplet.foobar", "urn"),
|
||||
|
@ -161,12 +169,7 @@ resource "digitalocean_droplet" "foo" {
|
|||
region = "nyc3"
|
||||
ipv6 = true
|
||||
vpc_uuid = digitalocean_vpc.foobar.id
|
||||
}
|
||||
|
||||
data "digitalocean_droplet" "foobar" {
|
||||
name = digitalocean_droplet.foo.name
|
||||
}
|
||||
`, randomTestName(), name)
|
||||
}`, randomTestName(), name)
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanDropletConfig_basicById(name string) string {
|
||||
|
@ -180,7 +183,7 @@ resource "digitalocean_droplet" "foo" {
|
|||
}
|
||||
|
||||
data "digitalocean_droplet" "foobar" {
|
||||
id = "${digitalocean_droplet.foo.id}"
|
||||
id = digitalocean_droplet.foo.id
|
||||
}
|
||||
`, name)
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ resource "digitalocean_droplet" "foo" {
|
|||
image = "centos-7-x64"
|
||||
region = "nyc3"
|
||||
ipv6 = true
|
||||
tags = ["${digitalocean_tag.foo.id}"]
|
||||
tags = [digitalocean_tag.foo.id]
|
||||
}
|
||||
`, tagName, name)
|
||||
}
|
||||
|
@ -214,11 +217,11 @@ resource "digitalocean_droplet" "foo" {
|
|||
image = "centos-7-x64"
|
||||
region = "nyc3"
|
||||
ipv6 = true
|
||||
tags = ["${digitalocean_tag.foo.id}"]
|
||||
tags = [digitalocean_tag.foo.id]
|
||||
}
|
||||
|
||||
data "digitalocean_droplet" "foobar" {
|
||||
tag = "${digitalocean_tag.foo.id}"
|
||||
tag = digitalocean_tag.foo.id
|
||||
}
|
||||
`, tagName, name)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanDroplets() *schema.Resource {
|
||||
|
|
|
@ -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 TestAccDataSourceDigitalOceanDroplets_Basic(t *testing.T) {
|
||||
|
@ -36,9 +36,9 @@ data "digitalocean_droplets" "result" {
|
|||
}
|
||||
}
|
||||
`, name1)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: resourcesConfig,
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"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 dataSourceDigitalOceanFloatingIp() *schema.Resource {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 TestAccDataSourceDigitalOceanFloatingIp_Basic(t *testing.T) {
|
||||
|
@ -16,9 +16,9 @@ func TestAccDataSourceDigitalOceanFloatingIp_Basic(t *testing.T) {
|
|||
|
||||
expectedURNRegEx, _ := regexp.Compile(`do:floatingip:(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanFloatingIpConfig_basic,
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanImage() *schema.Resource {
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanImage_Basic(t *testing.T) {
|
||||
|
@ -18,10 +18,10 @@ func TestAccDigitalOceanImage_Basic(t *testing.T) {
|
|||
var snapshotsId []int
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanDropletConfig_basic(rInt),
|
||||
|
@ -63,10 +63,10 @@ func TestAccDigitalOceanImage_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccDigitalOceanImage_PublicSlug(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanImageConfig_slug("ubuntu-18-04-x64"),
|
||||
|
@ -74,7 +74,7 @@ func TestAccDigitalOceanImage_PublicSlug(t *testing.T) {
|
|||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_image.foobar", "slug", "ubuntu-18-04-x64"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_image.foobar", "min_disk_size", "20"),
|
||||
"data.digitalocean_image.foobar", "min_disk_size", "15"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_image.foobar", "private", "false"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanImages() *schema.Resource {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"strconv"
|
||||
"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"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanImages_Basic(t *testing.T) {
|
||||
|
@ -20,9 +20,9 @@ data "digitalocean_images" "ubuntu" {
|
|||
}
|
||||
}
|
||||
`
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanKubernetesCluster() *schema.Resource {
|
||||
|
|
|
@ -6,22 +6,35 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 TestAccDataSourceDigitalOceanKubernetesCluster_Basic(t *testing.T) {
|
||||
t.Parallel()
|
||||
rName := randomTestName()
|
||||
var k8s godo.KubernetesCluster
|
||||
resourceConfig := testAccDigitalOceanKubernetesConfigForDataSource(testClusterVersion16, rName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_kubernetes_cluster" "foobar" {
|
||||
name = digitalocean_kubernetes_cluster.foo.name
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
ExternalProviders: map[string]resource.ExternalProvider{
|
||||
"kubernetes": {
|
||||
Source: "hashicorp/kubernetes",
|
||||
VersionConstraint: "1.13.2",
|
||||
},
|
||||
},
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccDigitalOceanKubernetesConfigWithDataSource(testClusterVersion16, rName),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanKubernetesClusterExists("data.digitalocean_kubernetes_cluster.foobar", &k8s),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_kubernetes_cluster.foobar", "name", rName),
|
||||
|
@ -36,7 +49,7 @@ func TestAccDataSourceDigitalOceanKubernetesCluster_Basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func testAccDigitalOceanKubernetesConfigWithDataSource(version string, rName string) string {
|
||||
func testAccDigitalOceanKubernetesConfigForDataSource(version string, rName string) string {
|
||||
return fmt.Sprintf(`%s
|
||||
|
||||
resource "digitalocean_kubernetes_cluster" "foo" {
|
||||
|
@ -55,12 +68,7 @@ resource "digitalocean_kubernetes_cluster" "foo" {
|
|||
priority = "high"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "digitalocean_kubernetes_cluster" "foobar" {
|
||||
name = "${digitalocean_kubernetes_cluster.foo.name}"
|
||||
}
|
||||
`, version, rName)
|
||||
}`, version, rName)
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanKubernetesClusterExists(n string, cluster *godo.KubernetesCluster) resource.TestCheckFunc {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanKubernetesVersions() *schema.Resource {
|
||||
|
|
|
@ -5,14 +5,13 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanKubernetesVersions_Basic(t *testing.T) {
|
||||
t.Parallel()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanKubernetesVersionsConfig_basic),
|
||||
|
@ -26,10 +25,9 @@ func TestAccDataSourceDigitalOceanKubernetesVersions_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccDataSourceDigitalOceanKubernetesVersions_Filtered(t *testing.T) {
|
||||
t.Parallel()
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanKubernetesVersionsConfig_filtered),
|
||||
|
@ -43,14 +41,13 @@ func TestAccDataSourceDigitalOceanKubernetesVersions_Filtered(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccDataSourceDigitalOceanKubernetesVersions_CreateCluster(t *testing.T) {
|
||||
t.Parallel()
|
||||
rName := randomTestName()
|
||||
var k8s godo.KubernetesCluster
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanKubernetesVersionsConfig_create, rName),
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanLoadbalancer() *schema.Resource {
|
||||
|
@ -89,7 +89,6 @@ func dataSourceDigitalOceanLoadbalancer() *schema.Resource {
|
|||
"healthcheck": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"protocol": {
|
||||
|
@ -135,7 +134,6 @@ func dataSourceDigitalOceanLoadbalancer() *schema.Resource {
|
|||
"sticky_sessions": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"type": {
|
||||
|
|
|
@ -6,40 +6,51 @@ import (
|
|||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/setutil"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanLoadBalancer_Basic(t *testing.T) {
|
||||
var loadbalancer godo.LoadBalancer
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := testAccCheckDataSourceDigitalOceanLoadBalancerConfig_basic(testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_loadbalancer" "foobar" {
|
||||
name = digitalocean_loadbalancer.foo.name
|
||||
}`
|
||||
|
||||
expectedURNRegEx, _ := regexp.Compile(`do:loadbalancer:[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}`)
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanLoadBalancerConfig_basic(rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanLoadBalancerExists("data.digitalocean_loadbalancer.foobar", &loadbalancer),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "name", fmt.Sprintf("loadbalancer-%d", rInt)),
|
||||
"data.digitalocean_loadbalancer.foobar", "name", testName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "region", "nyc3"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.#", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.entry_port", "80"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.entry_protocol", "http"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.target_port", "80"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.target_protocol", "http"),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"data.digitalocean_loadbalancer.foobar",
|
||||
"forwarding_rule.*",
|
||||
map[string]string{
|
||||
"entry_port": "80",
|
||||
"entry_protocol": "http",
|
||||
"target_port": "80",
|
||||
"target_protocol": "http",
|
||||
},
|
||||
),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "healthcheck.#", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -64,39 +75,51 @@ func TestAccDataSourceDigitalOceanLoadBalancer_Basic(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanLoadBalancer_multipleRules(t *testing.T) {
|
||||
var loadbalancer godo.LoadBalancer
|
||||
rName := randomTestName()
|
||||
testName := randomTestName()
|
||||
resourceConfig := testAccCheckDigitalOceanLoadbalancerConfig_multipleRules(testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_loadbalancer" "foobar" {
|
||||
name = digitalocean_loadbalancer.foobar.name
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanLoadbalancerDestroy,
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanLoadbalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanLoadbalancerConfig_multipleRules(rName) + testAccCheckDataSourceDigitalOceanLoadBalancerConfig_multipleRules,
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeAggregateTestCheckFunc(
|
||||
testAccCheckDigitalOceanLoadbalancerExists("digitalocean_loadbalancer.foobar", &loadbalancer),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "name", rName),
|
||||
"data.digitalocean_loadbalancer.foobar", "name", testName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "region", "nyc3"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.#", "2"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.236988772.entry_port", "443"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.236988772.entry_protocol", "https"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.236988772.target_port", "443"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.236988772.target_protocol", "https"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.entry_port", "80"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.entry_protocol", "http"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.target_port", "80"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_loadbalancer.foobar", "forwarding_rule.192790336.target_protocol", "http"),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"data.digitalocean_loadbalancer.foobar",
|
||||
"forwarding_rule.*",
|
||||
map[string]string{
|
||||
"entry_port": "443",
|
||||
"entry_protocol": "https",
|
||||
"target_port": "443",
|
||||
"target_protocol": "https",
|
||||
},
|
||||
),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"data.digitalocean_loadbalancer.foobar",
|
||||
"forwarding_rule.*",
|
||||
map[string]string{
|
||||
"entry_port": "80",
|
||||
"entry_protocol": "http",
|
||||
"target_port": "80",
|
||||
"target_protocol": "http",
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -133,7 +156,7 @@ func testAccCheckDataSourceDigitalOceanLoadBalancerExists(n string, loadbalancer
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanLoadBalancerConfig_basic(rInt int) string {
|
||||
func testAccCheckDataSourceDigitalOceanLoadBalancerConfig_basic(testName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "digitalocean_tag" "foo" {
|
||||
name = "web"
|
||||
|
@ -142,7 +165,7 @@ resource "digitalocean_tag" "foo" {
|
|||
resource "digitalocean_droplet" "foo" {
|
||||
count = 2
|
||||
image = "ubuntu-18-04-x64"
|
||||
name = "foo-%d-${count.index}"
|
||||
name = "%s-${count.index}"
|
||||
region = "nyc3"
|
||||
size = "512mb"
|
||||
private_networking = true
|
||||
|
@ -150,7 +173,7 @@ resource "digitalocean_droplet" "foo" {
|
|||
}
|
||||
|
||||
resource "digitalocean_loadbalancer" "foo" {
|
||||
name = "loadbalancer-%d"
|
||||
name = "%s"
|
||||
region = "nyc3"
|
||||
|
||||
forwarding_rule {
|
||||
|
@ -168,16 +191,5 @@ resource "digitalocean_loadbalancer" "foo" {
|
|||
|
||||
droplet_tag = digitalocean_tag.foo.id
|
||||
depends_on = ["digitalocean_droplet.foo"]
|
||||
}`, testName, testName)
|
||||
}
|
||||
|
||||
data "digitalocean_loadbalancer" "foobar" {
|
||||
name = digitalocean_loadbalancer.foo.name
|
||||
}`, rInt, rInt)
|
||||
}
|
||||
|
||||
const (
|
||||
testAccCheckDataSourceDigitalOceanLoadBalancerConfig_multipleRules = `
|
||||
data "digitalocean_loadbalancer" "foobar" {
|
||||
name = digitalocean_loadbalancer.foobar.name
|
||||
}`
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanProject() *schema.Resource {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanProject_DefaultProject(t *testing.T) {
|
||||
|
@ -12,9 +12,9 @@ func TestAccDataSourceDigitalOceanProject_DefaultProject(t *testing.T) {
|
|||
data "digitalocean_project" "default" {
|
||||
}
|
||||
`
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
@ -30,27 +30,30 @@ data "digitalocean_project" "default" {
|
|||
|
||||
func TestAccDataSourceDigitalOceanProject_NonDefaultProject(t *testing.T) {
|
||||
nonDefaultProjectName := randomName("tf-acc-project-", 6)
|
||||
config := fmt.Sprintf(`
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_project" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
|
||||
name = "%s"
|
||||
}`, nonDefaultProjectName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_project" "bar" {
|
||||
id = digitalocean_project.foo.id
|
||||
id = digitalocean_project.foo.id
|
||||
}
|
||||
|
||||
data "digitalocean_project" "barfoo" {
|
||||
name = digitalocean_project.foo.name
|
||||
name = digitalocean_project.foo.name
|
||||
}
|
||||
`, nonDefaultProjectName)
|
||||
`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanProjectDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanProjectDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttrSet("data.digitalocean_project.bar", "id"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_project.bar", "is_default", "false"),
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanProjects() *schema.Resource {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanProjects_Basic(t *testing.T) {
|
||||
|
@ -57,10 +57,10 @@ data "digitalocean_projects" "both" {
|
|||
}
|
||||
}
|
||||
`, stagingProjectName, stagingProjectName)
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanProjectDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanProjectDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: resourcesConfig,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanRecord() *schema.Resource {
|
||||
|
|
|
@ -7,30 +7,48 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanRecord_Basic(t *testing.T) {
|
||||
var record godo.DomainRecord
|
||||
recordName := fmt.Sprintf("foo-%s", acctest.RandString(10))
|
||||
recordDomain := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10))
|
||||
recordType := "A"
|
||||
recordDomain := fmt.Sprintf("%s.com", randomTestName())
|
||||
recordName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_domain" "foo" {
|
||||
name = "%s"
|
||||
ip_address = "192.168.0.10"
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource "digitalocean_record" "foo" {
|
||||
domain = digitalocean_domain.foo.name
|
||||
type = "A"
|
||||
name = "%s"
|
||||
value = "192.168.0.10"
|
||||
}`, recordDomain, recordName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_record" "foobar" {
|
||||
name = digitalocean_record.foo.name
|
||||
domain = digitalocean_domain.foo.name
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanRecordConfig_basic, recordDomain, recordType, recordName),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanRecordExists("data.digitalocean_record.foobar", &record),
|
||||
testAccCheckDataSourceDigitalOceanRecordAttributes(&record, recordName, recordType),
|
||||
testAccCheckDataSourceDigitalOceanRecordAttributes(&record, recordName, "A"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_record.foobar", "name", recordName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_record.foobar", "type", recordType),
|
||||
"data.digitalocean_record.foobar", "type", "A"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -86,21 +104,3 @@ func testAccCheckDataSourceDigitalOceanRecordExists(n string, record *godo.Domai
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanRecordConfig_basic = `
|
||||
resource "digitalocean_domain" "foo" {
|
||||
name = "%s"
|
||||
ip_address = "192.168.0.10"
|
||||
}
|
||||
|
||||
resource "digitalocean_record" "foo" {
|
||||
domain = "${digitalocean_domain.foo.name}"
|
||||
type = "%s"
|
||||
name = "%s"
|
||||
value = "192.168.0.10"
|
||||
}
|
||||
|
||||
data "digitalocean_record" "foobar" {
|
||||
name = "${digitalocean_record.foo.name}"
|
||||
domain = "${digitalocean_domain.foo.name}"
|
||||
}`
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanRegion() *schema.Resource {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanRegion_Basic(t *testing.T) {
|
||||
|
@ -13,9 +13,9 @@ data "digitalocean_region" "lon1" {
|
|||
slug = "lon1"
|
||||
}
|
||||
`
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
@ -37,9 +37,9 @@ data "digitalocean_region" "xyz5" {
|
|||
slug = "xyz5"
|
||||
}
|
||||
`
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanRegions() *schema.Resource {
|
||||
|
|
|
@ -3,11 +3,10 @@ package digitalocean
|
|||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"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"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanRegions_Basic(t *testing.T) {
|
||||
|
@ -52,9 +51,9 @@ data "digitalocean_regions" "filtered" {
|
|||
}
|
||||
}
|
||||
`
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: configNoFilter,
|
||||
|
@ -68,10 +67,9 @@ data "digitalocean_regions" "filtered" {
|
|||
}
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
key := fmt.Sprintf("regions.%d.available", i)
|
||||
v, ok := is.Attributes[key]
|
||||
if !ok || !strings.EqualFold(v, "true") {
|
||||
return fmt.Errorf("`available` != true for %s in %s", key, "data.digitalocean_regions.all")
|
||||
key := fmt.Sprintf("regions.%d.slug", i)
|
||||
if _, ok := is.Attributes[key]; !ok {
|
||||
return fmt.Errorf("missing key in instance state for %s in %s", key, "data.digitalocean_regions.all")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanSizes() *schema.Resource {
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"strconv"
|
||||
"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"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanSizes_Basic(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanSizesConfigBasic),
|
||||
|
@ -25,9 +25,9 @@ func TestAccDataSourceDigitalOceanSizes_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccDataSourceDigitalOceanSizes_WithFilterAndSort(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanSizesConfigWithFilterAndSort),
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanSpacesBucket() *schema.Resource {
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"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 dataSourceDigitalOceanSpacesBucketObject() *schema.Resource {
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanSpacesBucketObject_basic(t *testing.T) {
|
||||
|
@ -21,7 +21,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObject_basic(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
|
@ -56,7 +56,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObject_readableBody(t *testing.T)
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObject_allParams(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObject_LeadingSlash(t *testing.T)
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObject_MultipleSlashes(t *testing.
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
)
|
||||
|
||||
const keyRequestPageSize = 1000
|
||||
|
|
|
@ -4,9 +4,9 @@ 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/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanSpacesBucketObjects_basic(t *testing.T) {
|
||||
|
@ -14,7 +14,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObjects_basic(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObjects_all(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObjects_prefixes(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObjects_encoded(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ func TestAccDataSourceDigitalOceanSpacesBucketObjects_maxKeys(t *testing.T) {
|
|||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
PreventPostDestroyRefresh: true,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"regexp"
|
||||
"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 TestAccDataSourceDigitalOceanSpacesBucket_Basic(t *testing.T) {
|
||||
|
@ -31,10 +31,10 @@ data "digitalocean_spaces_bucket" "bucket" {
|
|||
config1 := resourceConfig
|
||||
config2 := config1 + datasourceConfig
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config1,
|
||||
|
@ -66,10 +66,10 @@ data "digitalocean_spaces_bucket" "bucket" {
|
|||
}
|
||||
`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: datasourceConfig,
|
||||
|
|
|
@ -2,7 +2,7 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanSpacesBuckets() *schema.Resource {
|
||||
|
|
|
@ -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 TestAccDataSourceDigitalOceanSpacesBuckets_Basic(t *testing.T) {
|
||||
|
@ -36,10 +36,10 @@ data "digitalocean_spaces_buckets" "result" {
|
|||
}
|
||||
`, bucketName1)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: bucketsConfig,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanSSHKey() *schema.Resource {
|
||||
|
|
|
@ -10,15 +10,14 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanSSHKey_Basic(t *testing.T) {
|
||||
var key godo.Key
|
||||
keyName := fmt.Sprintf("foo-%s", acctest.RandString(10))
|
||||
keyName := randomTestName()
|
||||
|
||||
pubKey, err := testAccGenerateDataSourceDigitalOceanSSHKeyPublic()
|
||||
if err != nil {
|
||||
|
@ -26,12 +25,26 @@ func TestAccDataSourceDigitalOceanSSHKey_Basic(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_ssh_key" "foo" {
|
||||
name = "%s"
|
||||
public_key = "%s"
|
||||
}`, keyName, pubKey)
|
||||
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_ssh_key" "foobar" {
|
||||
name = digitalocean_ssh_key.foo.name
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanSSHKeyConfig_basic, keyName, pubKey),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanSSHKeyExists("data.digitalocean_ssh_key.foobar", &key),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -92,13 +105,3 @@ func testAccGenerateDataSourceDigitalOceanSSHKeyPublic() (string, error) {
|
|||
|
||||
return strings.TrimSpace(string(ssh.MarshalAuthorizedKey(publicKey))), nil
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanSSHKeyConfig_basic = `
|
||||
resource "digitalocean_ssh_key" "foo" {
|
||||
name = "%s"
|
||||
public_key = "%s"
|
||||
}
|
||||
|
||||
data "digitalocean_ssh_key" "foobar" {
|
||||
name = "${digitalocean_ssh_key.foo.name}"
|
||||
}`
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanTag() *schema.Resource {
|
||||
|
|
|
@ -6,21 +6,31 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanTag_Basic(t *testing.T) {
|
||||
var tag godo.Tag
|
||||
tagName := fmt.Sprintf("foo-%s", acctest.RandString(10))
|
||||
tagName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_tag" "foo" {
|
||||
name = "%s"
|
||||
}`, tagName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_tag" "foobar" {
|
||||
name = "${digitalocean_tag.foo.name}"
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanTagConfig_basic, tagName),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanTagExists("data.digitalocean_tag.foobar", &tag),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -72,12 +82,3 @@ func testAccCheckDataSourceDigitalOceanTagExists(n string, tag *godo.Tag) resour
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanTagConfig_basic = `
|
||||
resource "digitalocean_tag" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
|
||||
data "digitalocean_tag" "foobar" {
|
||||
name = "${digitalocean_tag.foo.name}"
|
||||
}`
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/datalist"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dataSourceDigitalOceanTags() *schema.Resource {
|
||||
|
|
|
@ -5,51 +5,51 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanTags_Basic(t *testing.T) {
|
||||
var tag godo.Tag
|
||||
tagName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanTagsConfig_basic, tagName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanTagExists("digitalocean_tag.foo", &tag),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_tags.foobar", "tags.0.name", tagName),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.resource_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "total_resource_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "droplets_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "images_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "volumes_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "volume_snapshots_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tag.foobar", "databases_count"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanTagsConfig_basic = `
|
||||
resourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_tag" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
|
||||
}`, tagName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_tags" "foobar" {
|
||||
filter {
|
||||
key = "name"
|
||||
values = [digitalocean_tag.foo.name]
|
||||
}
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanTagExists("digitalocean_tag.foo", &tag),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_tags.foobar", "tags.0.name", tagName),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.total_resource_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.droplets_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.images_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.volumes_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.volume_snapshots_count"),
|
||||
resource.TestCheckResourceAttrSet(
|
||||
"data.digitalocean_tags.foobar", "tags.0.databases_count"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanVolume() *schema.Resource {
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanVolumeSnapshot() *schema.Resource {
|
||||
|
|
|
@ -6,24 +6,32 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanVolumeSnapshot_basic(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_basic, testName, testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name = digitalocean_volume_snapshot.foo.name
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_basic, rInt, rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanVolumeSnapshotExists("data.digitalocean_volume_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "size", "0"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "min_disk_size", "100"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "regions.#", "1"),
|
||||
|
@ -37,17 +45,26 @@ func TestAccDataSourceDigitalOceanVolumeSnapshot_basic(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanVolumeSnapshot_regex(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_basic, testName, testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name_regex = "^${digitalocean_volume_snapshot.foo.name}"
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_regex, rInt, rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanVolumeSnapshotExists("data.digitalocean_volume_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "size", "0"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "min_disk_size", "100"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "regions.#", "1"),
|
||||
|
@ -61,17 +78,38 @@ func TestAccDataSourceDigitalOceanVolumeSnapshot_regex(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanVolumeSnapshot_region(t *testing.T) {
|
||||
var snapshot godo.Snapshot
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
nycResourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_basic, testName, testName)
|
||||
lonResourceConfig := fmt.Sprintf(`
|
||||
resource "digitalocean_volume" "bar" {
|
||||
region = "lon1"
|
||||
name = "volume-lon-%s"
|
||||
size = 100
|
||||
description = "peace makes plenty"
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource "digitalocean_volume_snapshot" "bar" {
|
||||
name = "%s-snapshot"
|
||||
volume_id = digitalocean_volume.bar.id
|
||||
}`, testName, testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
name = digitalocean_volume_snapshot.bar.name
|
||||
region = "lon1"
|
||||
}`
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDataSourceDigitalOceanVolumeSnapshot_region, rInt, rInt, rInt, rInt),
|
||||
Config: nycResourceConfig + lonResourceConfig,
|
||||
},
|
||||
{
|
||||
Config: nycResourceConfig + lonResourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanVolumeSnapshotExists("data.digitalocean_volume_snapshot.foobar", &snapshot),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("snapshot-%d", rInt)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "name", fmt.Sprintf("%s-snapshot", testName)),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "size", "0"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "min_disk_size", "100"),
|
||||
resource.TestCheckResourceAttr("data.digitalocean_volume_snapshot.foobar", "regions.#", "1"),
|
||||
|
@ -115,68 +153,14 @@ func testAccCheckDataSourceDigitalOceanVolumeSnapshotExists(n string, snapshot *
|
|||
const testAccCheckDataSourceDigitalOceanVolumeSnapshot_basic = `
|
||||
resource "digitalocean_volume" "foo" {
|
||||
region = "nyc1"
|
||||
name = "volume-%d"
|
||||
name = "%s-volume"
|
||||
size = 100
|
||||
description = "peace makes plenty"
|
||||
}
|
||||
|
||||
resource "digitalocean_volume_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
volume_id = "${digitalocean_volume.foo.id}"
|
||||
name = "%s-snapshot"
|
||||
volume_id = digitalocean_volume.foo.id
|
||||
tags = ["foo","bar"]
|
||||
}
|
||||
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name = "${digitalocean_volume_snapshot.foo.name}"
|
||||
}`
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanVolumeSnapshot_regex = `
|
||||
resource "digitalocean_volume" "foo" {
|
||||
region = "nyc1"
|
||||
name = "volume-%d"
|
||||
size = 100
|
||||
description = "peace makes plenty"
|
||||
}
|
||||
|
||||
resource "digitalocean_volume_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
volume_id = "${digitalocean_volume.foo.id}"
|
||||
tags = ["foo","bar"]
|
||||
}
|
||||
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
most_recent = true
|
||||
name_regex = "^${digitalocean_volume_snapshot.foo.name}"
|
||||
}`
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanVolumeSnapshot_region = `
|
||||
resource "digitalocean_volume" "foo" {
|
||||
region = "nyc1"
|
||||
name = "volume-nyc-%d"
|
||||
size = 100
|
||||
description = "peace makes plenty"
|
||||
}
|
||||
|
||||
resource "digitalocean_volume" "bar" {
|
||||
region = "lon1"
|
||||
name = "volume-lon-%d"
|
||||
size = 100
|
||||
description = "peace makes plenty"
|
||||
}
|
||||
|
||||
resource "digitalocean_volume_snapshot" "foo" {
|
||||
name = "snapshot-%d"
|
||||
volume_id = "${digitalocean_volume.foo.id}"
|
||||
tags = ["foo","bar"]
|
||||
}
|
||||
|
||||
resource "digitalocean_volume_snapshot" "bar" {
|
||||
name = "snapshot-%d"
|
||||
volume_id = "${digitalocean_volume.bar.id}"
|
||||
}
|
||||
|
||||
data "digitalocean_volume_snapshot" "foobar" {
|
||||
name = "${digitalocean_volume_snapshot.bar.name}"
|
||||
region = "lon1"
|
||||
}`
|
||||
`
|
||||
|
|
|
@ -7,27 +7,34 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"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 TestAccDataSourceDigitalOceanVolume_Basic(t *testing.T) {
|
||||
var volume godo.Volume
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := testAccCheckDataSourceDigitalOceanVolumeConfig_basic(testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_volume" "foobar" {
|
||||
name = digitalocean_volume.foo.name
|
||||
}`
|
||||
|
||||
expectedURNRegEx, _ := regexp.Compile(`do:volume:[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}`)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanVolumeConfig_basic(rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanVolumeExists("data.digitalocean_volume.foobar", &volume),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_volume.foobar", "name", fmt.Sprintf("volume-%d", rInt)),
|
||||
"data.digitalocean_volume.foobar", "name", fmt.Sprintf("%s-volume", testName)),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_volume.foobar", "region", "nyc3"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -45,18 +52,27 @@ func TestAccDataSourceDigitalOceanVolume_Basic(t *testing.T) {
|
|||
|
||||
func TestAccDataSourceDigitalOceanVolume_RegionScoped(t *testing.T) {
|
||||
var volume godo.Volume
|
||||
rInt := acctest.RandInt()
|
||||
testName := randomTestName()
|
||||
resourceConfig := testAccCheckDataSourceDigitalOceanVolumeConfig_region_scoped(testName)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_volume" "foobar" {
|
||||
name = digitalocean_volume.foo.name
|
||||
region = "lon1"
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanVolumeConfig_region_scoped(rInt),
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDataSourceDigitalOceanVolumeExists("data.digitalocean_volume.foobar", &volume),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_volume.foobar", "name", fmt.Sprintf("volume-%d", rInt)),
|
||||
"data.digitalocean_volume.foobar", "name", fmt.Sprintf("%s-volume", testName)),
|
||||
resource.TestCheckResourceAttr(
|
||||
"data.digitalocean_volume.foobar", "region", "lon1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -101,37 +117,28 @@ func testAccCheckDataSourceDigitalOceanVolumeExists(n string, volume *godo.Volum
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanVolumeConfig_basic(rInt int) string {
|
||||
func testAccCheckDataSourceDigitalOceanVolumeConfig_basic(testName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "digitalocean_volume" "foo" {
|
||||
region = "nyc3"
|
||||
name = "volume-%d"
|
||||
name = "%s-volume"
|
||||
size = 10
|
||||
tags = ["foo","bar"]
|
||||
}`, testName)
|
||||
}
|
||||
|
||||
data "digitalocean_volume" "foobar" {
|
||||
name = "${digitalocean_volume.foo.name}"
|
||||
}`, rInt)
|
||||
}
|
||||
|
||||
func testAccCheckDataSourceDigitalOceanVolumeConfig_region_scoped(rInt int) string {
|
||||
func testAccCheckDataSourceDigitalOceanVolumeConfig_region_scoped(testName string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "digitalocean_volume" "foo" {
|
||||
region = "nyc3"
|
||||
name = "volume-%d"
|
||||
name = "%s-volume"
|
||||
size = 10
|
||||
tags = ["foo","bar"]
|
||||
}
|
||||
|
||||
resource "digitalocean_volume" "bar" {
|
||||
region = "lon1"
|
||||
name = "volume-%d"
|
||||
name = "%s-volume"
|
||||
size = 20
|
||||
}
|
||||
|
||||
data "digitalocean_volume" "foobar" {
|
||||
name = "${digitalocean_volume.foo.name}"
|
||||
region = "lon1"
|
||||
}`, rInt, rInt)
|
||||
}`, testName, testName)
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 dataSourceDigitalOceanVPC() *schema.Resource {
|
||||
|
|
|
@ -5,20 +5,27 @@ import (
|
|||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDataSourceDigitalOceanVPC_ByName(t *testing.T) {
|
||||
vpcName := randomTestName()
|
||||
vpcDesc := "A description for the VPC"
|
||||
vpcConfigByName := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVPCConfig_Basic, vpcName, vpcDesc)
|
||||
resourceConfig := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVPCConfig_Basic, vpcName, vpcDesc)
|
||||
dataSourceConfig := `
|
||||
data "digitalocean_vpc" "foobar" {
|
||||
name = digitalocean_vpc.foobar.name
|
||||
}`
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: vpcConfigByName,
|
||||
Config: resourceConfig,
|
||||
},
|
||||
{
|
||||
Config: resourceConfig + dataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDigitalOceanVPCExists("data.digitalocean_vpc.foobar"),
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -43,9 +50,9 @@ func TestAccDataSourceDigitalOceanVPC_RegionDefault(t *testing.T) {
|
|||
vpcDropletName := randomTestName()
|
||||
vpcConfigRegionDefault := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVPCConfig_RegionDefault, vpcDropletName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: vpcConfigRegionDefault,
|
||||
|
@ -67,9 +74,9 @@ func TestAccDataSourceDigitalOceanVPC_ExpectErrors(t *testing.T) {
|
|||
vpcName := randomTestName()
|
||||
vpcNotExist := fmt.Sprintf(testAccCheckDataSourceDigitalOceanVPCConfig_DoesNotExist, vpcName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDataSourceDigitalOceanVPCConfig_MissingRegionDefault,
|
||||
|
@ -88,12 +95,7 @@ resource "digitalocean_vpc" "foobar" {
|
|||
name = "%s"
|
||||
description = "%s"
|
||||
region = "nyc3"
|
||||
}
|
||||
|
||||
data "digitalocean_vpc" "foobar" {
|
||||
name = digitalocean_vpc.foobar.name
|
||||
}
|
||||
`
|
||||
}`
|
||||
|
||||
const testAccCheckDataSourceDigitalOceanVPCConfig_RegionDefault = `
|
||||
// Create Droplet to ensure default VPC exists
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func domainSchema() map[string]*schema.Schema {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func dropletSchema() map[string]*schema.Schema {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package digitalocean
|
||||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
|
||||
type commonFilter struct {
|
||||
|
|
|
@ -3,8 +3,9 @@ package digitalocean
|
|||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"hash/crc32"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func HashString(s string) string {
|
||||
|
@ -22,3 +23,18 @@ func HashStringStateFunc() schema.SchemaStateFunc {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hashcode.String in the terraform-plugin-sdk was made internal to the SDK in v2.
|
||||
// Embed the implementation here to allow same hash function to continue to be used
|
||||
// by the code in this provider that used it for hash computation.
|
||||
func SDKHashString(s string) int {
|
||||
v := int(crc32.ChecksumIEEE([]byte(s)))
|
||||
if v >= 0 {
|
||||
return v
|
||||
}
|
||||
if -v >= 0 {
|
||||
return -v
|
||||
}
|
||||
// v == MinInt
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
type imageListFunc func(ctx context.Context, opt *godo.ListOptions) ([]godo.Image, *godo.Response, error)
|
||||
|
@ -70,6 +70,10 @@ func imageSchema() map[string]*schema.Schema {
|
|||
Type: schema.TypeString,
|
||||
Description: "error message associated with the image",
|
||||
},
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Description: "a description of the image",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,6 +142,7 @@ func flattenDigitalOceanImage(rawImage interface{}, meta interface{}) (map[strin
|
|||
"tags": flattenedTags,
|
||||
"status": image.Status,
|
||||
"error_message": image.ErrorMessage,
|
||||
"description": image.Description,
|
||||
|
||||
// Legacy attributes
|
||||
"image": strconv.Itoa(image.ID),
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanApp_importBasic(t *testing.T) {
|
||||
|
|
|
@ -3,8 +3,8 @@ package digitalocean
|
|||
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 TestAccDigitalOceanCertificate_importBasic(t *testing.T) {
|
||||
|
@ -13,10 +13,10 @@ func TestAccDigitalOceanCertificate_importBasic(t *testing.T) {
|
|||
|
||||
privateKeyMaterial, leafCertMaterial, certChainMaterial := generateTestCertMaterial(t)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanCertificateDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanCertificateDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanCertificateConfig_basic(rInt, privateKeyMaterial, leafCertMaterial, certChainMaterial),
|
||||
|
|
|
@ -3,16 +3,16 @@ package digitalocean
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanContainerRegistry_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_container_registry.foobar"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanContainerRegistryDestroy,
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanContainerRegistryDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanContainerRegistryConfig_basic,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"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 TestAccDigitalOceanDatabaseConnectionPool_importBasic(t *testing.T) {
|
||||
|
@ -15,10 +15,10 @@ func TestAccDigitalOceanDatabaseConnectionPool_importBasic(t *testing.T) {
|
|||
databaseName := randomTestName()
|
||||
databaseConnectionPoolName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseConnectionPoolDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseConnectionPoolDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseConnectionPoolConfigBasic, databaseName, databaseConnectionPoolName),
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanDatabaseDB_importBasic(t *testing.T) {
|
||||
|
@ -16,10 +16,10 @@ func TestAccDigitalOceanDatabaseDB_importBasic(t *testing.T) {
|
|||
databaseClusterName := fmt.Sprintf("foobar-test-terraform-%s", acctest.RandString(10))
|
||||
databaseDBName := fmt.Sprintf("foobar-test-db-terraform-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseDBDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseDBDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseDBConfigBasic, databaseClusterName, databaseDBName),
|
||||
|
|
|
@ -6,18 +6,18 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"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 TestAccDigitalOceanDatabaseFirewall_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_database_firewall.example"
|
||||
databaseClusterName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseFirewallDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseFirewallDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseFirewallConfigBasic, databaseClusterName),
|
||||
|
|
|
@ -6,25 +6,34 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanDatabaseReplica_importBasic(t *testing.T) {
|
||||
var database godo.Database
|
||||
resourceName := "digitalocean_database_replica.read-01"
|
||||
databaseName := fmt.Sprintf("foobar-test-terraform-%s", acctest.RandString(10))
|
||||
databaseReplicaName := fmt.Sprintf("read-01-test-terraform-%s", acctest.RandString(10))
|
||||
databaseName := randomTestName()
|
||||
databaseReplicaName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseReplicaDestroy,
|
||||
databaseConfig := fmt.Sprintf(testAccCheckDigitalOceanDatabaseClusterConfigBasic, databaseName)
|
||||
replicaConfig := fmt.Sprintf(testAccCheckDigitalOceanDatabaseReplicaConfigBasic, databaseReplicaName)
|
||||
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseReplicaDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseReplicaConfigBasic, databaseName, databaseReplicaName),
|
||||
Config: databaseConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckDigitalOceanDatabaseClusterExists("digitalocean_database_cluster.foobar", &database),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: databaseConfig + replicaConfig,
|
||||
},
|
||||
|
||||
{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"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 TestAccDigitalOceanDatabaseUser_importBasic(t *testing.T) {
|
||||
|
@ -15,10 +15,10 @@ func TestAccDigitalOceanDatabaseUser_importBasic(t *testing.T) {
|
|||
databaseClusterName := randomTestName()
|
||||
databaseUserName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseUserDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDatabaseUserDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseUserConfigBasic, databaseClusterName, databaseUserName),
|
||||
|
|
|
@ -5,18 +5,18 @@ import (
|
|||
|
||||
"fmt"
|
||||
|
||||
"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 TestAccDigitalOceanDomain_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_domain.foobar"
|
||||
domainName := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDomainDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDomainDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDomainConfig_basic, domainName),
|
||||
|
|
|
@ -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 TestAccDigitalOceanDropletSnapshot_importBasic(t *testing.T) {
|
||||
|
@ -13,10 +13,10 @@ func TestAccDigitalOceanDropletSnapshot_importBasic(t *testing.T) {
|
|||
rInt1 := acctest.RandInt()
|
||||
rInt2 := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeSnapshotDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeSnapshotDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanDropletSnapshotConfig_basic, rInt1, rInt2),
|
||||
|
|
|
@ -7,19 +7,19 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanDroplet_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_droplet.foobar"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanDropletConfig_basic(rInt),
|
||||
|
@ -49,10 +49,10 @@ func TestAccDigitalOceanDroplet_ImportWithNoImageSlug(t *testing.T) {
|
|||
var droplet godo.Droplet
|
||||
var snapshotId []int
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanDropletConfig_basic(rInt),
|
||||
|
|
|
@ -3,17 +3,17 @@ package digitalocean
|
|||
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 TestAccDigitalOceanFloatingIP_importBasicRegion(t *testing.T) {
|
||||
resourceName := "digitalocean_floating_ip.foobar"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanFloatingIPDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanFloatingIPDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanFloatingIPConfig_region,
|
||||
|
@ -32,10 +32,10 @@ func TestAccDigitalOceanFloatingIP_importBasicDroplet(t *testing.T) {
|
|||
resourceName := "digitalocean_floating_ip.foobar"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanFloatingIPDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanFloatingIPDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanFloatingIPConfig_droplet(rInt),
|
||||
|
|
|
@ -8,17 +8,17 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 TestAccDigitalOceanKubernetesCluster_ImportBasic(t *testing.T) {
|
||||
clusterName := randomTestName()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccDigitalOceanKubernetesConfigBasic(testClusterVersion16, clusterName),
|
||||
|
@ -114,10 +114,10 @@ resource "digitalocean_kubernetes_node_pool" "barfoo" {
|
|||
}
|
||||
`, testClusterVersion16, testName1, testName2)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanKubernetesNodePool_Import(t *testing.T) {
|
||||
|
@ -35,10 +35,10 @@ resource "digitalocean_kubernetes_node_pool" "barfoo" {
|
|||
`, testClusterVersion16, testName1, testName2)
|
||||
resourceName := "digitalocean_kubernetes_node_pool.barfoo"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanKubernetesClusterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
|
|
|
@ -3,18 +3,18 @@ package digitalocean
|
|||
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 TestAccDigitalOceanLoadBalancer_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_loadbalancer.foobar"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanLoadbalancerDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanLoadbalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanLoadbalancerConfig_basic(rInt),
|
||||
|
|
|
@ -6,18 +6,18 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"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 TestAccDigitalOceanRecord_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_record.foobar"
|
||||
domainName := fmt.Sprintf("foobar-test-terraform-%s.com", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanRecordDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanRecordDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanRecordConfig_basic, domainName),
|
||||
|
|
|
@ -5,18 +5,18 @@ import (
|
|||
"regexp"
|
||||
"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 TestAccDigitalOceanBucket_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_spaces_bucket.bucket"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanBucketDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccDigitalOceanBucketConfigImport(rInt),
|
||||
|
|
|
@ -3,8 +3,8 @@ package digitalocean
|
|||
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 TestAccDigitalOceanSSHKey_importBasic(t *testing.T) {
|
||||
|
@ -15,10 +15,10 @@ func TestAccDigitalOceanSSHKey_importBasic(t *testing.T) {
|
|||
t.Fatalf("Cannot generate test SSH key pair: %s", err)
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanSSHKeyDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanSSHKeyDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanSSHKeyConfig_basic(rInt, publicKeyMaterial),
|
||||
|
|
|
@ -3,16 +3,16 @@ package digitalocean
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanTag_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_tag.foobar"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanTagDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanTagDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccCheckDigitalOceanTagConfig_basic,
|
||||
|
|
|
@ -5,18 +5,18 @@ import (
|
|||
|
||||
"fmt"
|
||||
|
||||
"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 TestAccDigitalOceanVolumeSnapshot_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_volume_snapshot.foobar"
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeSnapshotDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeSnapshotDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanVolumeSnapshotConfig_basic, rInt, rInt),
|
||||
|
|
|
@ -6,18 +6,18 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"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 TestAccDigitalOceanVolume_importBasic(t *testing.T) {
|
||||
resourceName := "digitalocean_volume.foobar"
|
||||
volumeName := fmt.Sprintf("volume-%s", acctest.RandString(10))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanVolumeDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: fmt.Sprintf(testAccCheckDigitalOceanVolumeConfig_basic, volumeName),
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccDigitalOceanVPC_importBasic(t *testing.T) {
|
||||
|
@ -14,10 +14,10 @@ func TestAccDigitalOceanVPC_importBasic(t *testing.T) {
|
|||
vpcName := randomTestName()
|
||||
vpcCreateConfig := fmt.Sprintf(testAccCheckDigitalOceanVPCConfig_Basic, vpcName, "A description for the VPC")
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckDigitalOceanVPCDestroy,
|
||||
resource.ParallelTest(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
ProviderFactories: testAccProviderFactories,
|
||||
CheckDestroy: testAccCheckDigitalOceanVPCDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: vpcCreateConfig,
|
||||
|
|
|
@ -8,9 +8,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func loadbalancerStateRefreshFunc(client *godo.Client, loadbalancerId string) resource.StateRefreshFunc {
|
||||
|
@ -141,7 +140,7 @@ func hashForwardingRules(v interface{}) int {
|
|||
buf.WriteString(fmt.Sprintf("%t-", v.(bool)))
|
||||
}
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
return SDKHashString(buf.String())
|
||||
}
|
||||
|
||||
func flattenDropletIds(list []int) *schema.Set {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func projectSchema() map[string]*schema.Schema {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package digitalocean
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
// Provider returns a schema.Provider for DigitalOcean.
|
||||
func Provider() terraform.ResourceProvider {
|
||||
func Provider() *schema.Provider {
|
||||
p := &schema.Provider{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"token": {
|
||||
|
|
|
@ -1,45 +1,56 @@
|
|||
package digitalocean
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/terraform"
|
||||
"github.com/terraform-providers/terraform-provider-kubernetes/kubernetes"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
||||
)
|
||||
|
||||
const testNamePrefix = "tf-acc-test-"
|
||||
|
||||
var (
|
||||
testAccProviders map[string]terraform.ResourceProvider
|
||||
testAccProvider *schema.Provider
|
||||
)
|
||||
var testAccProvider *schema.Provider
|
||||
var testAccProviders map[string]*schema.Provider
|
||||
var testAccProviderFactories map[string]func() (*schema.Provider, error)
|
||||
|
||||
func init() {
|
||||
testAccProvider = Provider().(*schema.Provider)
|
||||
testAccProviders = map[string]terraform.ResourceProvider{
|
||||
testAccProvider = Provider()
|
||||
testAccProviders = map[string]*schema.Provider{
|
||||
"digitalocean": testAccProvider,
|
||||
"kubernetes": kubernetes.Provider(),
|
||||
}
|
||||
testAccProviderFactories = map[string]func() (*schema.Provider, error){
|
||||
"digitalocean": func() (*schema.Provider, error) {
|
||||
return testAccProvider, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if v := os.Getenv("DIGITALOCEAN_TOKEN"); v == "" {
|
||||
t.Fatal("DIGITALOCEAN_TOKEN must be set for acceptance tests")
|
||||
}
|
||||
|
||||
err := testAccProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(nil))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLOverride(t *testing.T) {
|
||||
|
@ -51,11 +62,16 @@ func TestURLOverride(t *testing.T) {
|
|||
"api_endpoint": customEndpoint,
|
||||
}
|
||||
|
||||
err := rawProvider.Configure(terraform.NewResourceConfigRaw(raw))
|
||||
meta := rawProvider.(*schema.Provider).Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil: err: %s", err)
|
||||
diags := rawProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw))
|
||||
if diags.HasError() {
|
||||
t.Fatalf("provider configure failed: %s", diagnosticsToString(diags))
|
||||
}
|
||||
|
||||
meta := rawProvider.Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil")
|
||||
}
|
||||
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
if client.BaseURL.String() != customEndpoint {
|
||||
t.Fatalf("Expected %s, got %s", customEndpoint, client.BaseURL.String())
|
||||
|
@ -68,17 +84,31 @@ func TestURLDefault(t *testing.T) {
|
|||
"token": "12345",
|
||||
}
|
||||
|
||||
err := rawProvider.Configure(terraform.NewResourceConfigRaw(raw))
|
||||
meta := rawProvider.(*schema.Provider).Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil: err: %s", err)
|
||||
diags := rawProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw))
|
||||
if diags.HasError() {
|
||||
t.Fatalf("provider configure failed: %s", diagnosticsToString(diags))
|
||||
}
|
||||
|
||||
meta := rawProvider.Meta()
|
||||
if meta == nil {
|
||||
t.Fatal("Expected metadata, got nil")
|
||||
}
|
||||
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
if client.BaseURL.String() != "https://api.digitalocean.com" {
|
||||
t.Fatalf("Expected %s, got %s", "https://api.digitalocean.com", client.BaseURL.String())
|
||||
}
|
||||
}
|
||||
|
||||
func diagnosticsToString(diags diag.Diagnostics) string {
|
||||
diagsAsStrings := make([]string, len(diags))
|
||||
for i, diag := range diags {
|
||||
diagsAsStrings[i] = diag.Summary
|
||||
}
|
||||
|
||||
return strings.Join(diagsAsStrings, "; ")
|
||||
}
|
||||
|
||||
func TestSpaceAPIDefaultEndpoint(t *testing.T) {
|
||||
rawProvider := Provider()
|
||||
raw := map[string]interface{}{
|
||||
|
@ -87,13 +117,19 @@ func TestSpaceAPIDefaultEndpoint(t *testing.T) {
|
|||
"spaces_secret_key": "xyzzy",
|
||||
}
|
||||
|
||||
err := rawProvider.Configure(terraform.NewResourceConfigRaw(raw))
|
||||
meta := rawProvider.(*schema.Provider).Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil: err: %s", err)
|
||||
diags := rawProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw))
|
||||
if diags.HasError() {
|
||||
t.Fatalf("provider configure failed: %s", diagnosticsToString(diags))
|
||||
}
|
||||
|
||||
client, err := meta.(*CombinedConfig).spacesClient("sfo2")
|
||||
meta := rawProvider.Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil")
|
||||
}
|
||||
|
||||
var client *session.Session
|
||||
var err error
|
||||
client, err = meta.(*CombinedConfig).spacesClient("sfo2")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create Spaces client: %s", err)
|
||||
}
|
||||
|
@ -115,13 +151,19 @@ func TestSpaceAPIEndpointOverride(t *testing.T) {
|
|||
"spaces_secret_key": "xyzzy",
|
||||
}
|
||||
|
||||
err := rawProvider.Configure(terraform.NewResourceConfigRaw(raw))
|
||||
meta := rawProvider.(*schema.Provider).Meta()
|
||||
if meta == nil {
|
||||
t.Fatalf("Expected metadata, got nil: err: %s", err)
|
||||
diags := rawProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw))
|
||||
if diags.HasError() {
|
||||
t.Fatalf("provider configure failed: %s", diagnosticsToString(diags))
|
||||
}
|
||||
|
||||
client, err := meta.(*CombinedConfig).spacesClient("sfo2")
|
||||
meta := rawProvider.Meta()
|
||||
if meta == nil {
|
||||
t.Fatal("Expected metadata, got nil")
|
||||
}
|
||||
|
||||
var client *session.Session
|
||||
var err error
|
||||
client, err = meta.(*CombinedConfig).spacesClient("sfo2")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create Spaces client: %s", err)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func getDigitalOceanRegions(meta interface{}) ([]interface{}, error) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func resourceDigitalOceanApp() *schema.Resource {
|
||||
|
|
|
@ -7,9 +7,11 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/digitalocean/terraform-provider-digitalocean/internal/setutil"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"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 init() {
|
||||
|
@ -196,12 +198,15 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
|
|||
"digitalocean_app.foobar", "spec.0.name", appName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.#", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.key", "FOO"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.value", "bar"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.scope", "RUN_AND_BUILD_TIME"),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"digitalocean_app.foobar",
|
||||
"spec.0.service.0.env.*",
|
||||
map[string]string{
|
||||
"key": "FOO",
|
||||
"value": "bar",
|
||||
"scope": "RUN_AND_BUILD_TIME",
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -212,18 +217,24 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
|
|||
"digitalocean_app.foobar", "spec.0.name", appName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.#", "2"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.key", "FOO"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.value", "bar"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.3118534296.scope", "RUN_AND_BUILD_TIME"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1776096292.key", "FIZZ"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1776096292.value", "pop"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1776096292.scope", "BUILD_TIME"),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"digitalocean_app.foobar",
|
||||
"spec.0.service.0.env.*",
|
||||
map[string]string{
|
||||
"key": "FOO",
|
||||
"value": "bar",
|
||||
"scope": "RUN_AND_BUILD_TIME",
|
||||
},
|
||||
),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"digitalocean_app.foobar",
|
||||
"spec.0.service.0.env.*",
|
||||
map[string]string{
|
||||
"key": "FIZZ",
|
||||
"value": "pop",
|
||||
"scope": "BUILD_TIME",
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -234,12 +245,15 @@ func TestAccDigitalOceanApp_Envs(t *testing.T) {
|
|||
"digitalocean_app.foobar", "spec.0.name", appName),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.#", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1277866902.key", "FOO"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1277866902.value", "baz"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"digitalocean_app.foobar", "spec.0.service.0.env.1277866902.scope", "RUN_TIME"),
|
||||
setutil.TestCheckTypeSetElemNestedAttrs(
|
||||
"digitalocean_app.foobar",
|
||||
"spec.0.service.0.env.*",
|
||||
map[string]string{
|
||||
"key": "FOO",
|
||||
"value": "baz",
|
||||
"scope": "RUN_TIME",
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue