Commit Graph

12 Commits

Author SHA1 Message Date
Tom Dyas f50c276f6e
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>
2020-10-16 15:50:20 -04:00
Andrew Starr-Bochicchio c0a4d34366
Use certificate name as primary identifier instead of ID (#500)
* Use certificate name as primary identifier instead of ID
When the certificate type is lets_encrypt, the certificate ID will change when
it's renewed, so we have to rely on the certificate name as the primary
identifier instead.

* Support running LB and cert tests in parallel

* Add state migration for Certificate resource

* Add state migration for LoadBalancer resource

* Use resource.ParallelTest for tests.

* Use a v0.12-style StateUpgrader.

* loadbalancer: Fix panic in buildLoadBalancerRequest

* Add fallback to flattenForwardingRules to prevent error state when a hardcoded UUID is used.

* Fix typo in findCertificateByName.

* Deprecate forwarding_rule.certificate_id in favor of forwarding_rule.certificate_name

* Use a v0.12-style StateUpgrader for load balancer migration.

* Handle cert ID change in CDN resource.

* Clean up structure.

* Update documentation.

Co-authored-by: Steven Normore <snormore@digitalocean.com>
2020-10-13 15:45:34 -04:00
Andrew Starr-Bochicchio 726215a1fd
Don't store full certificate data in state file (Fixes: #156). (#349) 2019-12-16 12:24:57 -05:00
Paul Stack 655147c103 Upgrade to terraform-plugin-sdk (#321)
* Upgrade to terraform-plugin-sdk

After following the [guide](https://www.terraform.io/docs/extend/plugin-sdk.html#using-tf-sdk-migrator)

Check

```
▶ GO111MODULE=on tf-sdk-migrator check
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.8: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.
```

Migrate

```
▶ GO111MODULE=on tf-sdk-migrator migrate
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.8: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.

Rewriting provider go.mod file...
Rewriting SDK package imports...
Running `go mod tidy`...
Success! Provider is migrated to github.com/hashicorp/terraform-plugin-sdk v1.1.0.

It looks like this provider vendors dependencies. Don't forget to run `go mod vendor`.
Make sure to review all changes and run all tests.
```

* Fix build under go 1.13.x.
2019-10-22 17:44:03 -04:00
Andrew Starr-Bochicchio dfe37acbc0 Certificates: Move attribute validation from CustomizeDiff to Create (Fixes: #163).
When CustomizeDiff is run for a new resource, it does not have access to the
current state. In the digitalocean_certificate resource, we are using a
CustomizeDiff function to validate that certain attributes are used together
depending on the certificate type. When the value for one of those attributes
is interpolated, as in the case of generating a cert using the acme provider,
the validation fails since it depends on reading the value from state. As state
is not present, the value is interpreted as empty.

From the CustomizeDiff doc string:

> // The phases Terraform runs this in, and the state available via functions
> // like Get and GetChange, are as follows:
> //
> //  * New resource: One run with no state

https://godoc.org/github.com/hashicorp/terraform/helper/schema#Resource

This PR moves the validation from the CustomizeDiff function into the
Create function as well as adding acceptance tests:

```
$ make testacc TESTARGS='-run=TestAccDigitalOceanCertificate_ExpectedErrors'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccDigitalOceanCertificate_ExpectedE$
?       github.com/terraform-providers/terraform-provider-digitalocean  [no test files]
=== RUN   TestAccDigitalOceanCertificate_ExpectedErrors
--- PASS: TestAccDigitalOceanCertificate_ExpectedErrors (0.10s)
PASS
ok      github.com/terraform-providers/terraform-provider-digitalocean/digitalocean     (cached)
```
2019-03-28 14:13:22 -04:00
Andrew Starr-Bochicchio baf11ca2cc Update all resources and datasources to use new method of accessing the godo client. 2019-01-07 18:48:17 -05:00
Andrew Starr-Bochicchio 9be11e1e5c Add explanitory comment. 2018-10-04 14:26:28 -04:00
Andrew Starr-Bochicchio bc91bcb4f6 Suppress diff for dns names on custom certificate resources (Fixes: #146). 2018-10-04 11:41:55 -04:00
Tilen Faganel c2e8f204f0
Fixed a debug message typo 2018-09-04 20:02:05 +01:00
Tilen Faganel b0da0f9bb3
Added support for LetsEncrypt issued certificates 2018-08-30 15:43:32 +01:00
Andrew Starr-Bochicchio 1a5c46a1ac
Add importability for Load Balancers and Certificate. (#104)
* Added importability for load balancer

* Added importability, go fmt'ed

* Added importability for DNS records

* added importability for certificates

* Added import notes for DNS records and load balancers

* Added import tests

* Added random int for test configs

* Added certificates for the test to import

* Fixed docs, added certificate importability on docs

* Make TestAccDigitalOceanCertificate_importBasic pass by reusing certificate generation from resource_digitalocean_certificate_test.go

* Fix importablity of Load Balancer Droplet droplet_ids.

* Revert "Added importability for DNS records"

This reverts commit 94b1f69fe756c862125d0b899d49eca74f7bd591.

* Remove mention of record imports in docs.

* Remove digitalocean/import_digitalocean_record_test.go
2018-06-25 19:38:10 -04:00
Jake Champlin ddd64aa789
Transfer digitalocean provider 2017-06-06 11:45:13 -04:00
Renamed from resource_digitalocean_certificate.go (Browse further)