Update all resources and datasources to use new method of accessing the godo client.
This commit is contained in:
parent
58719590e7
commit
baf11ca2cc
|
@ -52,7 +52,7 @@ func dataSourceDigitalOceanCertificate() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanCertificateRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ func testAccCheckDataSourceDigitalOceanCertificateExists(n string, certificate *
|
|||
return fmt.Errorf("No certificate ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundCertificate, _, err := client.Certificates.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/helper/validation"
|
||||
)
|
||||
|
@ -36,7 +35,7 @@ func dataSourceDigitalOceanDomain() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ func testAccCheckDataSourceDigitalOceanDomainExists(n string, domain *godo.Domai
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundDomain, _, err := client.Domains.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ func dataSourceDigitalOceanDroplet() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func dataSourceDigitalOceanDropletSnapshot() *schema.Resource {
|
|||
|
||||
// dataSourceDoSnapshotRead performs the Snapshot lookup.
|
||||
func dataSourceDigitalOceanDropletSnapshotRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name, hasName := d.GetOk("name")
|
||||
nameRegex, hasNameRegex := d.GetOk("name_regex")
|
||||
|
|
|
@ -79,7 +79,7 @@ func TestAccDataSourceDigitalOceanDropletSnapshot_region(t *testing.T) {
|
|||
|
||||
func testAccCheckDataSourceDigitalOceanDropletSnapshotExists(n string, snapshot *godo.Snapshot) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ func testAccCheckDataSourceDigitalOceanDropletExists(n string, droplet *godo.Dro
|
|||
return fmt.Errorf("No droplet ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(rs.Primary.ID)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/helper/validation"
|
||||
)
|
||||
|
@ -36,7 +35,7 @@ func dataSourceDigitalOceanFloatingIp() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
ipAddress := d.Get("ip_address").(string)
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func testAccCheckDataSourceDigitalOceanFloatingIpExists(n string, floatingIp *go
|
|||
return fmt.Errorf("No floating ip ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundFloatingIp, _, err := client.FloatingIPs.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ func dataSourceDigitalOceanImage() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanImageRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name, hasName := d.GetOk("name")
|
||||
slug, hasSlug := d.GetOk("slug")
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestAccDigitalOceanImage_PublicSlug(t *testing.T) {
|
|||
|
||||
func takeSnapshotsOfDroplet(rInt int, droplet *godo.Droplet, snapshotsId *[]int) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
for i := 0; i < 3; i++ {
|
||||
err := takeSnapshotOfDroplet(rInt, i%2, droplet)
|
||||
if err != nil {
|
||||
|
@ -106,7 +106,7 @@ func takeSnapshotsOfDroplet(rInt int, droplet *godo.Droplet, snapshotsId *[]int)
|
|||
}
|
||||
|
||||
func takeSnapshotOfDroplet(rInt, sInt int, droplet *godo.Droplet) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
action, _, err := client.DropletActions.Snapshot(context.Background(), (*droplet).ID, fmt.Sprintf("snap-%d-%d", rInt, sInt))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -119,7 +119,7 @@ func deleteDropletSnapshots(snapshotsId *[]int) resource.TestCheckFunc {
|
|||
return func(s *terraform.State) error {
|
||||
log.Printf("Deleting Droplet snapshots")
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
snapshots := *snapshotsId
|
||||
for _, value := range snapshots {
|
||||
|
|
|
@ -172,7 +172,7 @@ func dataSourceDigitalOceanLoadbalancer() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanLoadbalancerRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func testAccCheckDataSourceDigitalOceanLoadBalancerExists(n string, loadbalancer
|
|||
return fmt.Errorf("No Load Balancer ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundLoadbalancer, _, err := client.LoadBalancers.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ func dataSourceDigitalOceanRecord() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanRecordRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
domain := d.Get("domain").(string)
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ func testAccCheckDataSourceDigitalOceanRecordAttributes(record *godo.DomainRecor
|
|||
|
||||
func testAccCheckDataSourceDigitalOceanRecordExists(n string, record *godo.DomainRecord) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ func dataSourceDigitalOceanSSHKey() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanSSHKeyRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ func testAccCheckDataSourceDigitalOceanSSHKeyExists(n string, key *godo.Key) res
|
|||
return fmt.Errorf("No ssh key ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(rs.Primary.ID)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -24,7 +23,7 @@ func dataSourceDigitalOceanTag() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanTagRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func testAccCheckDataSourceDigitalOceanTagExists(n string, tag *godo.Tag) resour
|
|||
return fmt.Errorf("No tag ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundTag, _, err := client.Tags.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ func dataSourceDigitalOceanVolume() *schema.Resource {
|
|||
}
|
||||
|
||||
func dataSourceDigitalOceanVolumeRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name := d.Get("name").(string)
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func dataSourceDigitalOceanVolumeSnapshot() *schema.Resource {
|
|||
|
||||
// dataSourceDoSnapshotRead performs the Snapshot lookup.
|
||||
func dataSourceDigitalOceanVolumeSnapshotRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
name, hasName := d.GetOk("name")
|
||||
nameRegex, hasNameRegex := d.GetOk("name_regex")
|
||||
|
|
|
@ -82,7 +82,7 @@ func TestAccDataSourceDigitalOceanVolumeSnapshot_region(t *testing.T) {
|
|||
|
||||
func testAccCheckDataSourceDigitalOceanVolumeSnapshotExists(n string, snapshot *godo.Snapshot) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ func testAccCheckDataSourceDigitalOceanVolumeExists(n string, volume *godo.Volum
|
|||
return fmt.Errorf("No Volume ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundVolume, _, err := client.Storage.GetVolume(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ func TestAccDigitalOceanDroplet_ImportWithNoImageSlug(t *testing.T) {
|
|||
|
||||
func takeDropletSnapshot(rInt int, droplet *godo.Droplet, snapshotId *[]int) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
action, _, err := client.DropletActions.Snapshot(context.Background(), (*droplet).ID, fmt.Sprintf("snap-%d", rInt))
|
||||
if err != nil {
|
||||
|
|
|
@ -140,7 +140,7 @@ func buildCertificateRequest(d *schema.ResourceData) (*godo.CertificateRequest,
|
|||
}
|
||||
|
||||
func resourceDigitalOceanCertificateCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Create a Certificate Request")
|
||||
|
||||
|
@ -175,7 +175,7 @@ func resourceDigitalOceanCertificateCreate(d *schema.ResourceData, meta interfac
|
|||
}
|
||||
|
||||
func resourceDigitalOceanCertificateRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Reading the details of the Certificate %s", d.Id())
|
||||
cert, resp, err := client.Certificates.Get(context.Background(), d.Id())
|
||||
|
@ -205,7 +205,7 @@ func resourceDigitalOceanCertificateRead(d *schema.ResourceData, meta interface{
|
|||
}
|
||||
|
||||
func resourceDigitalOceanCertificateDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting Certificate: %s", d.Id())
|
||||
_, err := client.Certificates.Delete(context.Background(), d.Id())
|
||||
|
@ -242,7 +242,7 @@ func flattenDigitalOceanCertificateDomains(domains []string) *schema.Set {
|
|||
}
|
||||
|
||||
func newCertificateStateRefreshFunc(d *schema.ResourceData, meta interface{}) resource.StateRefreshFunc {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
// Retrieve the certificate properties
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestAccDigitalOceanCertificate_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanCertificateDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_certificate" {
|
||||
|
@ -79,7 +79,7 @@ func testAccCheckDigitalOceanCertificateExists(n string, cert *godo.Certificate)
|
|||
return fmt.Errorf("No Certificate ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
c, _, err := client.Certificates.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func resourceDigitalOceanDomain() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDomainCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
// Build up our creation options
|
||||
|
||||
|
@ -63,7 +63,7 @@ func resourceDigitalOceanDomainCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
domain, resp, err := client.Domains.Get(context.Background(), d.Id())
|
||||
if err != nil {
|
||||
|
@ -83,7 +83,7 @@ func resourceDigitalOceanDomainRead(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDomainDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting Domain: %s", d.Id())
|
||||
_, err := client.Domains.Delete(context.Background(), d.Id())
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestAccDigitalOceanDomain_WithoutIp(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanDomainDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_domain" {
|
||||
|
@ -101,7 +101,7 @@ func testAccCheckDigitalOceanDomainExists(n string, domain *godo.Domain) resourc
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundDomain, _, err := client.Domains.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ func resourceDigitalOceanDroplet() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
image := d.Get("image").(string)
|
||||
|
||||
|
@ -281,7 +281,7 @@ func resourceDigitalOceanDropletCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -388,7 +388,7 @@ func findIPv4AddrByType(d *godo.Droplet, addrType string) string {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -406,7 +406,7 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
// Wait for power off
|
||||
_, err = waitForDropletAttribute(d, "off", []string{"active"}, "status", client)
|
||||
_, err = waitForDropletAttribute(d, "off", []string{"active"}, "status", meta)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"Error waiting for droplet (%s) to become powered off: %s", d.Id(), err)
|
||||
|
@ -557,7 +557,7 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -625,7 +625,7 @@ func waitForDropletAttribute(
|
|||
// cleaner and more efficient
|
||||
func newDropletStateRefreshFunc(
|
||||
d *schema.ResourceData, attribute string, meta interface{}) resource.StateRefreshFunc {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
return func() (interface{}, string, error) {
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -672,14 +672,14 @@ func powerOnAndWait(d *schema.ResourceData, meta interface{}) error {
|
|||
return fmt.Errorf("invalid droplet id: %v", err)
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
_, _, err = client.DropletActions.PowerOn(context.Background(), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait for power on
|
||||
_, err = waitForDropletAttribute(d, "active", []string{"off"}, "status", client)
|
||||
_, err = waitForDropletAttribute(d, "active", []string{"off"}, "status", meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ func detachVolumeIDOnDroplet(d *schema.ResourceData, volumeID string, meta inter
|
|||
if err != nil {
|
||||
return fmt.Errorf("invalid droplet id: %v", err)
|
||||
}
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
action, _, err := client.StorageActions.DetachByDropletID(context.Background(), volumeID, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error detaching volume %q from droplet (%s): %s", volumeID, d.Id(), err)
|
||||
|
|
|
@ -56,7 +56,7 @@ func resourceDigitalOceanDropletSnapshot() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletSnapshotCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
resourceId, _ := strconv.Atoi(d.Get("droplet_id").(string))
|
||||
action, _, err := client.DropletActions.Snapshot(context.Background(), resourceId, d.Get("name").(string))
|
||||
|
@ -86,7 +86,7 @@ func resourceDigitalOceanDropletSnapshotCreate(d *schema.ResourceData, meta inte
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletSnapshotRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
snapshot, resp, err := client.Snapshots.Get(context.Background(), d.Id())
|
||||
if err != nil {
|
||||
|
@ -110,7 +110,7 @@ func resourceDigitalOceanDropletSnapshotRead(d *schema.ResourceData, meta interf
|
|||
}
|
||||
|
||||
func resourceDigitalOceanDropletSnapshotDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting snaphot: %s", d.Id())
|
||||
_, err := client.Snapshots.Delete(context.Background(), d.Id())
|
||||
|
|
|
@ -27,7 +27,7 @@ func testSweepDropletSnapshots(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
snapshots, _, err := client.Snapshots.ListDroplet(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -71,7 +71,7 @@ func TestAccDigitalOceanDropletSnapshot_Basic(t *testing.T) {
|
|||
|
||||
func testAccCheckDigitalOceanDropletSnapshotExists(n string, snapshot *godo.Snapshot) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
|
@ -99,7 +99,7 @@ func testAccCheckDigitalOceanDropletSnapshotExists(n string, snapshot *godo.Snap
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanDropletSnapshotDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_droplet_snapshot" {
|
||||
|
|
|
@ -28,7 +28,7 @@ func testSweepDroplets(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
droplets, _, err := client.Droplets.List(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -452,7 +452,7 @@ func TestAccDigitalOceanDroplet_conditionalVolumes(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanDropletDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_droplet" {
|
||||
|
@ -607,7 +607,7 @@ func testAccCheckDigitalOceanDropletExists(n string, droplet *godo.Droplet) reso
|
|||
return fmt.Errorf("No Droplet ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(rs.Primary.ID)
|
||||
if err != nil {
|
||||
|
|
|
@ -193,7 +193,7 @@ func resourceDigitalOceanFirewall() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFirewallCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
opts, err := firewallRequest(d, client)
|
||||
if err != nil {
|
||||
|
@ -216,7 +216,7 @@ func resourceDigitalOceanFirewallCreate(d *schema.ResourceData, meta interface{}
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFirewallRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
// Retrieve the firewall properties for updating the state
|
||||
firewall, resp, err := client.Firewalls.Get(context.Background(), d.Id())
|
||||
|
@ -256,7 +256,7 @@ func resourceDigitalOceanFirewallRead(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFirewallUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
opts, err := firewallRequest(d, client)
|
||||
if err != nil {
|
||||
|
@ -274,7 +274,7 @@ func resourceDigitalOceanFirewallUpdate(d *schema.ResourceData, meta interface{}
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFirewallDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting firewall: %s", d.Id())
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ resource "digitalocean_firewall" "foobar" {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanFirewallDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_firewall" {
|
||||
|
@ -344,7 +344,7 @@ func testAccCheckDigitalOceanFirewallExists(n string, firewall *godo.Firewall) r
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
foundFirewall, _, err := client.Firewalls.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ func resourceDigitalOceanFloatingIp() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Create a FloatingIP In a Region")
|
||||
regionOpts := &godo.FloatingIPCreateRequest{
|
||||
|
@ -80,7 +80,7 @@ func resourceDigitalOceanFloatingIpCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
if d.HasChange("droplet_id") {
|
||||
if v, ok := d.GetOk("droplet_id"); ok {
|
||||
|
@ -116,7 +116,7 @@ func resourceDigitalOceanFloatingIpUpdate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Reading the details of the FloatingIP %s", d.Id())
|
||||
floatingIp, resp, err := client.FloatingIPs.Get(context.Background(), d.Id())
|
||||
|
@ -143,7 +143,7 @@ func resourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpImport(rs *schema.ResourceData, v interface{}) ([]*schema.ResourceData, error) {
|
||||
client := v.(*godo.Client)
|
||||
client := v.(*CombinedConfig).godoClient()
|
||||
floatingIp, resp, err := client.FloatingIPs.Get(context.Background(), rs.Id())
|
||||
if resp.StatusCode != 404 {
|
||||
if err != nil {
|
||||
|
@ -162,7 +162,7 @@ func resourceDigitalOceanFloatingIpImport(rs *schema.ResourceData, v interface{}
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
if _, ok := d.GetOk("droplet_id"); ok {
|
||||
log.Printf("[INFO] Unassigning the Floating IP from the Droplet")
|
||||
|
@ -215,7 +215,7 @@ func waitForFloatingIPReady(
|
|||
|
||||
func newFloatingIPStateRefreshFunc(
|
||||
d *schema.ResourceData, attribute string, meta interface{}, actionId int) resource.StateRefreshFunc {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
log.Printf("[INFO] Assigning the Floating IP to the Droplet")
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/helper/validation"
|
||||
|
@ -40,7 +39,7 @@ func resourceDigitalOceanFloatingIpAssignment() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpAssignmentCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
ip_address := d.Get("ip_address").(string)
|
||||
droplet_id := d.Get("droplet_id").(int)
|
||||
|
@ -63,7 +62,7 @@ func resourceDigitalOceanFloatingIpAssignmentCreate(d *schema.ResourceData, meta
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpAssignmentRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
ip_address := d.Get("ip_address").(string)
|
||||
droplet_id := d.Get("droplet_id").(int)
|
||||
|
@ -83,7 +82,7 @@ func resourceDigitalOceanFloatingIpAssignmentRead(d *schema.ResourceData, meta i
|
|||
}
|
||||
|
||||
func resourceDigitalOceanFloatingIpAssignmentDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
ip_address := d.Get("ip_address").(string)
|
||||
droplet_id := d.Get("droplet_id").(int)
|
||||
|
@ -136,7 +135,7 @@ func waitForFloatingIPAssignmentReady(
|
|||
|
||||
func newFloatingIPAssignmentStateRefreshFunc(
|
||||
d *schema.ResourceData, attribute string, meta interface{}, actionId int) resource.StateRefreshFunc {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
return func() (interface{}, string, error) {
|
||||
|
||||
log.Printf("[INFO] Refreshing the Floating IP state")
|
||||
|
|
|
@ -98,7 +98,7 @@ func testAccCheckDigitalOceanFloatingIPAttachmentExists(n string) resource.TestC
|
|||
return err
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
// Try to find the FloatingIP
|
||||
foundFloatingIP, _, err := client.FloatingIPs.Get(context.Background(), fipID)
|
||||
|
|
|
@ -25,7 +25,7 @@ func testSweepFloatingIps(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
ips, _, err := client.FloatingIPs.List(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -99,7 +99,7 @@ func TestAccDigitalOceanFloatingIP_Droplet(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanFloatingIPDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_floating_ip" {
|
||||
|
@ -129,7 +129,7 @@ func testAccCheckDigitalOceanFloatingIPExists(n string, floatingIP *godo.Floatin
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
// Try to find the FloatingIP
|
||||
foundFloatingIP, _, err := client.FloatingIPs.Get(context.Background(), rs.Primary.ID)
|
||||
|
|
|
@ -285,7 +285,7 @@ func buildLoadBalancerRequest(d *schema.ResourceData) (*godo.LoadBalancerRequest
|
|||
}
|
||||
|
||||
func resourceDigitalOceanLoadbalancerCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Create a Loadbalancer Request")
|
||||
|
||||
|
@ -318,7 +318,7 @@ func resourceDigitalOceanLoadbalancerCreate(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceDigitalOceanLoadbalancerRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Reading the details of the Loadbalancer %s", d.Id())
|
||||
loadbalancer, resp, err := client.LoadBalancers.Get(context.Background(), d.Id())
|
||||
|
@ -360,7 +360,7 @@ func resourceDigitalOceanLoadbalancerRead(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceDigitalOceanLoadbalancerUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
lbOpts, err := buildLoadBalancerRequest(d)
|
||||
if err != nil {
|
||||
|
@ -377,7 +377,7 @@ func resourceDigitalOceanLoadbalancerUpdate(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceDigitalOceanLoadbalancerDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting Load Balancer: %s", d.Id())
|
||||
_, err := client.LoadBalancers.Delete(context.Background(), d.Id())
|
||||
|
|
|
@ -28,7 +28,7 @@ func testSweepLoadbalancer(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
lbs, _, err := client.LoadBalancers.List(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -294,7 +294,7 @@ func TestAccDigitalOceanLoadbalancer_stickySessions(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanLoadbalancerDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_loadbalancer" {
|
||||
|
@ -324,7 +324,7 @@ func testAccCheckDigitalOceanLoadbalancerExists(n string, loadbalancer *godo.Loa
|
|||
return fmt.Errorf("No Loadbalancer ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
lb, _, err := client.LoadBalancers.Get(context.Background(), rs.Primary.ID)
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ func resourceDigitalOceanRecord() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanRecordCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
newRecord, err := expandDigitalOceanRecordResource(d)
|
||||
if err != nil {
|
||||
|
@ -177,7 +177,7 @@ func resourceDigitalOceanRecordCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanRecordRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
domain := d.Get("domain").(string)
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -246,7 +246,7 @@ func resourceDigitalOceanRecordImport(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanRecordUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
domain := d.Get("domain").(string)
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
|
@ -269,7 +269,7 @@ func resourceDigitalOceanRecordUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanRecordDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
domain := d.Get("domain").(string)
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
|
|
|
@ -526,7 +526,7 @@ func TestAccDigitalOceanRecord_CaaUpdated(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanRecordDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_record" {
|
||||
|
@ -582,7 +582,7 @@ func testAccCheckDigitalOceanRecordExists(n string, record *godo.DomainRecord) r
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
domain := rs.Primary.Attributes["domain"]
|
||||
id, err := strconv.Atoi(rs.Primary.ID)
|
||||
|
|
|
@ -50,7 +50,7 @@ func resourceDigitalOceanSSHKeyPublicKeyDiffSuppress(k, old, new string, d *sche
|
|||
}
|
||||
|
||||
func resourceDigitalOceanSSHKeyCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
// Build up our creation options
|
||||
opts := &godo.KeyCreateRequest{
|
||||
|
@ -71,7 +71,7 @@ func resourceDigitalOceanSSHKeyCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanSSHKeyRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -98,7 +98,7 @@ func resourceDigitalOceanSSHKeyRead(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
|
||||
func resourceDigitalOceanSSHKeyUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
@ -123,7 +123,7 @@ func resourceDigitalOceanSSHKeyUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanSSHKeyDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(d.Id())
|
||||
if err != nil {
|
||||
|
|
|
@ -40,7 +40,7 @@ func TestAccDigitalOceanSSHKey_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanSSHKeyDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_ssh_key" {
|
||||
|
@ -75,7 +75,7 @@ func testAccCheckDigitalOceanSSHKeyExists(n string, key *godo.Key) resource.Test
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
id, err := strconv.Atoi(rs.Primary.ID)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,7 +30,7 @@ func resourceDigitalOceanTag() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanTagCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
// Build up our creation options
|
||||
opts := &godo.TagCreateRequest{
|
||||
|
@ -50,7 +50,7 @@ func resourceDigitalOceanTagCreate(d *schema.ResourceData, meta interface{}) err
|
|||
}
|
||||
|
||||
func resourceDigitalOceanTagRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
tag, resp, err := client.Tags.Get(context.Background(), d.Id())
|
||||
if err != nil {
|
||||
|
@ -70,7 +70,7 @@ func resourceDigitalOceanTagRead(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
func resourceDigitalOceanTagDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting tag: %s", d.Id())
|
||||
_, err := client.Tags.Delete(context.Background(), d.Id())
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestAccDigitalOceanTag_Basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanTagDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_tag" {
|
||||
|
@ -73,7 +73,7 @@ func testAccCheckDigitalOceanTagExists(n string, tag *godo.Tag) resource.TestChe
|
|||
return fmt.Errorf("No Record ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
// Try to find the tag
|
||||
foundTag, _, err := client.Tags.Get(context.Background(), rs.Primary.ID)
|
||||
|
|
|
@ -110,7 +110,7 @@ func resourceDigitalOceanVolume() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
opts := &godo.VolumeCreateRequest{
|
||||
Name: d.Get("name").(string),
|
||||
|
@ -149,7 +149,7 @@ func resourceDigitalOceanVolumeCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
id := d.Id()
|
||||
region := d.Get("region").(string)
|
||||
|
@ -174,7 +174,7 @@ func resourceDigitalOceanVolumeUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
volume, resp, err := client.Storage.GetVolume(context.Background(), d.Id())
|
||||
if err != nil {
|
||||
|
@ -206,7 +206,7 @@ func resourceDigitalOceanVolumeRead(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting volume: %s", d.Id())
|
||||
_, err := client.Storage.DeleteVolume(context.Background(), d.Id())
|
||||
|
@ -219,7 +219,7 @@ func resourceDigitalOceanVolumeDelete(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeImport(rs *schema.ResourceData, v interface{}) ([]*schema.ResourceData, error) {
|
||||
client := v.(*godo.Client)
|
||||
client := v.(*CombinedConfig).godoClient()
|
||||
volume, _, err := client.Storage.GetVolume(context.Background(), rs.Id())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/helper/validation"
|
||||
|
@ -37,7 +36,7 @@ func resourceDigitalOceanVolumeAttachment() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeAttachmentCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
dropletId := d.Get("droplet_id").(int)
|
||||
volumeId := d.Get("volume_id").(string)
|
||||
|
@ -84,7 +83,7 @@ func resourceDigitalOceanVolumeAttachmentCreate(d *schema.ResourceData, meta int
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeAttachmentRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
dropletId := d.Get("droplet_id").(int)
|
||||
volumeId := d.Get("volume_id").(string)
|
||||
|
@ -110,7 +109,7 @@ func resourceDigitalOceanVolumeAttachmentRead(d *schema.ResourceData, meta inter
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeAttachmentDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
dropletId := d.Get("droplet_id").(int)
|
||||
volumeId := d.Get("volume_id").(string)
|
||||
|
|
|
@ -183,7 +183,7 @@ func testAccCheckDigitalOceanVolumeAttachmentExists(rn string) resource.TestChec
|
|||
return fmt.Errorf("no volume ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
volumeId := rs.Primary.Attributes["volume_id"]
|
||||
dropletId, err := strconv.Atoi(rs.Primary.Attributes["droplet_id"])
|
||||
|
|
|
@ -59,7 +59,7 @@ func resourceDigitalOceanVolumeSnapshot() *schema.Resource {
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeSnapshotCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
opts := &godo.SnapshotCreateRequest{
|
||||
Name: d.Get("name").(string),
|
||||
|
@ -79,7 +79,7 @@ func resourceDigitalOceanVolumeSnapshotCreate(d *schema.ResourceData, meta inter
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeSnapshotRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
snapshot, resp, err := client.Snapshots.Get(context.Background(), d.Id())
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,7 @@ func resourceDigitalOceanVolumeSnapshotRead(d *schema.ResourceData, meta interfa
|
|||
}
|
||||
|
||||
func resourceDigitalOceanVolumeSnapshotDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
log.Printf("[INFO] Deleting snaphot: %s", d.Id())
|
||||
_, err := client.Snapshots.Delete(context.Background(), d.Id())
|
||||
|
|
|
@ -28,7 +28,7 @@ func testSweepVolumeSnapshots(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
snapshots, _, err := client.Snapshots.ListVolume(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -79,7 +79,7 @@ func TestAccDigitalOceanVolumeSnapshot_Basic(t *testing.T) {
|
|||
|
||||
func testAccCheckDigitalOceanVolumeSnapshotExists(n string, snapshot *godo.Snapshot) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
|
@ -107,7 +107,7 @@ func testAccCheckDigitalOceanVolumeSnapshotExists(n string, snapshot *godo.Snaps
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanVolumeSnapshotDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_volume_snapshot" {
|
||||
|
|
|
@ -28,7 +28,7 @@ func testSweepVolumes(region string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client := meta.(*godo.Client)
|
||||
client := meta.(*CombinedConfig).godoClient()
|
||||
|
||||
volumes, _, err := client.Storage.ListVolumes(context.Background(), nil)
|
||||
if err != nil {
|
||||
|
@ -96,7 +96,7 @@ func testAccCheckDigitalOceanVolumeExists(rn string, volume *godo.Volume) resour
|
|||
return fmt.Errorf("no volume ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
got, _, err := client.Storage.GetVolume(context.Background(), rs.Primary.ID)
|
||||
if err != nil {
|
||||
|
@ -112,7 +112,7 @@ func testAccCheckDigitalOceanVolumeExists(rn string, volume *godo.Volume) resour
|
|||
}
|
||||
|
||||
func testAccCheckDigitalOceanVolumeDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*godo.Client)
|
||||
client := testAccProvider.Meta().(*CombinedConfig).godoClient()
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "digitalocean_volume" {
|
||||
|
|
Loading…
Reference in New Issue