Chase API breakage from github.com/joyent/triton-go: add context.Background()

This commit is contained in:
Sean Chittenden 2017-05-10 14:54:57 -07:00
parent 4f590cb4fd
commit b6eb0abcef
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
10 changed files with 61 additions and 50 deletions

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
@ -109,7 +110,7 @@ func resourceFabricCreate(d *schema.ResourceData, meta interface{}) error {
routes[cidr] = ip routes[cidr] = ip
} }
fabric, err := client.Fabrics().CreateFabricNetwork(&triton.CreateFabricNetworkInput{ fabric, err := client.Fabrics().CreateFabricNetwork(context.Background(), &triton.CreateFabricNetworkInput{
FabricVLANID: d.Get("vlan_id").(int), FabricVLANID: d.Get("vlan_id").(int),
Name: d.Get("name").(string), Name: d.Get("name").(string),
Description: d.Get("description").(string), Description: d.Get("description").(string),
@ -134,7 +135,7 @@ func resourceFabricCreate(d *schema.ResourceData, meta interface{}) error {
func resourceFabricExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceFabricExists(d *schema.ResourceData, meta interface{}) (bool, error) {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return resourceExists(client.Fabrics().GetFabricNetwork(&triton.GetFabricNetworkInput{ return resourceExists(client.Fabrics().GetFabricNetwork(context.Background(), &triton.GetFabricNetworkInput{
FabricVLANID: d.Get("vlan_id").(int), FabricVLANID: d.Get("vlan_id").(int),
NetworkID: d.Id(), NetworkID: d.Id(),
})) }))
@ -143,7 +144,7 @@ func resourceFabricExists(d *schema.ResourceData, meta interface{}) (bool, error
func resourceFabricRead(d *schema.ResourceData, meta interface{}) error { func resourceFabricRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
fabric, err := client.Fabrics().GetFabricNetwork(&triton.GetFabricNetworkInput{ fabric, err := client.Fabrics().GetFabricNetwork(context.Background(), &triton.GetFabricNetworkInput{
FabricVLANID: d.Get("vlan_id").(int), FabricVLANID: d.Get("vlan_id").(int),
NetworkID: d.Id(), NetworkID: d.Id(),
}) })
@ -171,7 +172,7 @@ func resourceFabricRead(d *schema.ResourceData, meta interface{}) error {
func resourceFabricDelete(d *schema.ResourceData, meta interface{}) error { func resourceFabricDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return client.Fabrics().DeleteFabricNetwork(&triton.DeleteFabricNetworkInput{ return client.Fabrics().DeleteFabricNetwork(context.Background(), &triton.DeleteFabricNetworkInput{
FabricVLANID: d.Get("vlan_id").(int), FabricVLANID: d.Get("vlan_id").(int),
NetworkID: d.Id(), NetworkID: d.Id(),
}) })

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
"testing" "testing"
@ -48,7 +49,7 @@ func testCheckTritonFabricExists(name string) resource.TestCheckFunc {
return err return err
} }
exists, err := resourceExists(conn.Fabrics().GetFabricNetwork(&triton.GetFabricNetworkInput{ exists, err := resourceExists(conn.Fabrics().GetFabricNetwork(context.Background(), &triton.GetFabricNetworkInput{
FabricVLANID: vlanID, FabricVLANID: vlanID,
NetworkID: rs.Primary.ID, NetworkID: rs.Primary.ID,
})) }))
@ -77,7 +78,7 @@ func testCheckTritonFabricDestroy(s *terraform.State) error {
return err return err
} }
exists, err := resourceExists(conn.Fabrics().GetFabricNetwork(&triton.GetFabricNetworkInput{ exists, err := resourceExists(conn.Fabrics().GetFabricNetwork(context.Background(), &triton.GetFabricNetworkInput{
FabricVLANID: vlanID, FabricVLANID: vlanID,
NetworkID: rs.Primary.ID, NetworkID: rs.Primary.ID,
})) }))

View File

@ -1,6 +1,8 @@
package triton package triton
import ( import (
"context"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/joyent/triton-go" "github.com/joyent/triton-go"
) )
@ -45,7 +47,7 @@ func resourceFirewallRule() *schema.Resource {
func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error { func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
rule, err := client.Firewall().CreateFirewallRule(&triton.CreateFirewallRuleInput{ rule, err := client.Firewall().CreateFirewallRule(context.Background(), &triton.CreateFirewallRuleInput{
Rule: d.Get("rule").(string), Rule: d.Get("rule").(string),
Enabled: d.Get("enabled").(bool), Enabled: d.Get("enabled").(bool),
Description: d.Get("description").(string), Description: d.Get("description").(string),
@ -62,7 +64,7 @@ func resourceFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error
func resourceFirewallRuleExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceFirewallRuleExists(d *schema.ResourceData, meta interface{}) (bool, error) {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return resourceExists(client.Firewall().GetFirewallRule(&triton.GetFirewallRuleInput{ return resourceExists(client.Firewall().GetFirewallRule(context.Background(), &triton.GetFirewallRuleInput{
ID: d.Id(), ID: d.Id(),
})) }))
} }
@ -70,7 +72,7 @@ func resourceFirewallRuleExists(d *schema.ResourceData, meta interface{}) (bool,
func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error { func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
rule, err := client.Firewall().GetFirewallRule(&triton.GetFirewallRuleInput{ rule, err := client.Firewall().GetFirewallRule(context.Background(), &triton.GetFirewallRuleInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -89,7 +91,7 @@ func resourceFirewallRuleRead(d *schema.ResourceData, meta interface{}) error {
func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error { func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
_, err := client.Firewall().UpdateFirewallRule(&triton.UpdateFirewallRuleInput{ _, err := client.Firewall().UpdateFirewallRule(context.Background(), &triton.UpdateFirewallRuleInput{
ID: d.Id(), ID: d.Id(),
Rule: d.Get("rule").(string), Rule: d.Get("rule").(string),
Enabled: d.Get("enabled").(bool), Enabled: d.Get("enabled").(bool),
@ -105,7 +107,7 @@ func resourceFirewallRuleUpdate(d *schema.ResourceData, meta interface{}) error
func resourceFirewallRuleDelete(d *schema.ResourceData, meta interface{}) error { func resourceFirewallRuleDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return client.Firewall().DeleteFirewallRule(&triton.DeleteFirewallRuleInput{ return client.Firewall().DeleteFirewallRule(context.Background(), &triton.DeleteFirewallRuleInput{
ID: d.Id(), ID: d.Id(),
}) })
} }

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
@ -96,7 +97,7 @@ func testCheckTritonFirewallRuleExists(name string) resource.TestCheckFunc {
} }
conn := testAccProvider.Meta().(*triton.Client) conn := testAccProvider.Meta().(*triton.Client)
resp, err := conn.Firewall().GetFirewallRule(&triton.GetFirewallRuleInput{ resp, err := conn.Firewall().GetFirewallRule(context.Background(), &triton.GetFirewallRuleInput{
ID: rs.Primary.ID, ID: rs.Primary.ID,
}) })
if err != nil && triton.IsResourceNotFound(err) { if err != nil && triton.IsResourceNotFound(err) {
@ -121,7 +122,7 @@ func testCheckTritonFirewallRuleDestroy(s *terraform.State) error {
continue continue
} }
resp, err := conn.Firewall().GetFirewallRule(&triton.GetFirewallRuleInput{ resp, err := conn.Firewall().GetFirewallRule(context.Background(), &triton.GetFirewallRuleInput{
ID: rs.Primary.ID, ID: rs.Primary.ID,
}) })
if triton.IsResourceNotFound(err) { if triton.IsResourceNotFound(err) {

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"errors" "errors"
"strings" "strings"
@ -49,7 +50,7 @@ func resourceKeyCreate(d *schema.ResourceData, meta interface{}) error {
} }
} }
_, err := client.Keys().CreateKey(&triton.CreateKeyInput{ _, err := client.Keys().CreateKey(context.Background(), &triton.CreateKeyInput{
Name: d.Get("name").(string), Name: d.Get("name").(string),
Key: d.Get("key").(string), Key: d.Get("key").(string),
}) })
@ -65,7 +66,7 @@ func resourceKeyCreate(d *schema.ResourceData, meta interface{}) error {
func resourceKeyExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceKeyExists(d *schema.ResourceData, meta interface{}) (bool, error) {
client := meta.(*triton.Client) client := meta.(*triton.Client)
_, err := client.Keys().GetKey(&triton.GetKeyInput{ _, err := client.Keys().GetKey(context.Background(), &triton.GetKeyInput{
KeyName: d.Id(), KeyName: d.Id(),
}) })
if err != nil { if err != nil {
@ -78,7 +79,7 @@ func resourceKeyExists(d *schema.ResourceData, meta interface{}) (bool, error) {
func resourceKeyRead(d *schema.ResourceData, meta interface{}) error { func resourceKeyRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
key, err := client.Keys().GetKey(&triton.GetKeyInput{ key, err := client.Keys().GetKey(context.Background(), &triton.GetKeyInput{
KeyName: d.Id(), KeyName: d.Id(),
}) })
if err != nil { if err != nil {
@ -94,7 +95,7 @@ func resourceKeyRead(d *schema.ResourceData, meta interface{}) error {
func resourceKeyDelete(d *schema.ResourceData, meta interface{}) error { func resourceKeyDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return client.Keys().DeleteKey(&triton.DeleteKeyInput{ return client.Keys().DeleteKey(context.Background(), &triton.DeleteKeyInput{
KeyName: d.Id(), KeyName: d.Id(),
}) })
} }

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
"time" "time"
@ -78,7 +79,7 @@ func testCheckTritonKeyExists(name string) resource.TestCheckFunc {
} }
conn := testAccProvider.Meta().(*triton.Client) conn := testAccProvider.Meta().(*triton.Client)
key, err := conn.Keys().GetKey(&triton.GetKeyInput{ key, err := conn.Keys().GetKey(context.Background(), &triton.GetKeyInput{
KeyName: rs.Primary.ID, KeyName: rs.Primary.ID,
}) })
if err != nil { if err != nil {
@ -102,7 +103,7 @@ func testCheckTritonKeyDestroy(s *terraform.State) error {
continue continue
} }
key, err := conn.Keys().GetKey(&triton.GetKeyInput{ key, err := conn.Keys().GetKey(context.Background(), &triton.GetKeyInput{
KeyName: rs.Primary.ID, KeyName: rs.Primary.ID,
}) })
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"regexp" "regexp"
"time" "time"
@ -242,7 +243,7 @@ func resourceMachineCreate(d *schema.ResourceData, meta interface{}) error {
tags[k] = v.(string) tags[k] = v.(string)
} }
machine, err := client.Machines().CreateMachine(&triton.CreateMachineInput{ machine, err := client.Machines().CreateMachine(context.Background(), &triton.CreateMachineInput{
Name: d.Get("name").(string), Name: d.Get("name").(string),
Package: d.Get("package").(string), Package: d.Get("package").(string),
Image: d.Get("image").(string), Image: d.Get("image").(string),
@ -259,7 +260,7 @@ func resourceMachineCreate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{fmt.Sprintf(machineStateRunning)}, Target: []string{fmt.Sprintf(machineStateRunning)},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -286,7 +287,7 @@ func resourceMachineCreate(d *schema.ResourceData, meta interface{}) error {
func resourceMachineExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceMachineExists(d *schema.ResourceData, meta interface{}) (bool, error) {
client := meta.(*triton.Client) client := meta.(*triton.Client)
return resourceExists(client.Machines().GetMachine(&triton.GetMachineInput{ return resourceExists(client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
})) }))
} }
@ -294,14 +295,14 @@ func resourceMachineExists(d *schema.ResourceData, meta interface{}) (bool, erro
func resourceMachineRead(d *schema.ResourceData, meta interface{}) error { func resourceMachineRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
machine, err := client.Machines().GetMachine(&triton.GetMachineInput{ machine, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
return err return err
} }
nics, err := client.Machines().ListNICs(&triton.ListNICsInput{ nics, err := client.Machines().ListNICs(context.Background(), &triton.ListNICsInput{
MachineID: d.Id(), MachineID: d.Id(),
}) })
if err != nil { if err != nil {
@ -366,7 +367,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
oldName := oldNameInterface.(string) oldName := oldNameInterface.(string)
newName := newNameInterface.(string) newName := newNameInterface.(string)
err := client.Machines().RenameMachine(&triton.RenameMachineInput{ err := client.Machines().RenameMachine(context.Background(), &triton.RenameMachineInput{
ID: d.Id(), ID: d.Id(),
Name: newName, Name: newName,
}) })
@ -378,7 +379,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
Pending: []string{oldName}, Pending: []string{oldName},
Target: []string{newName}, Target: []string{newName},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -406,11 +407,11 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
var err error var err error
if len(tags) == 0 { if len(tags) == 0 {
err = client.Machines().DeleteMachineTags(&triton.DeleteMachineTagsInput{ err = client.Machines().DeleteMachineTags(context.Background(), &triton.DeleteMachineTagsInput{
ID: d.Id(), ID: d.Id(),
}) })
} else { } else {
err = client.Machines().ReplaceMachineTags(&triton.ReplaceMachineTagsInput{ err = client.Machines().ReplaceMachineTags(context.Background(), &triton.ReplaceMachineTagsInput{
ID: d.Id(), ID: d.Id(),
Tags: tags, Tags: tags,
}) })
@ -423,7 +424,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{expectedTagsMD5}, Target: []string{expectedTagsMD5},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -446,7 +447,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
if d.HasChange("package") { if d.HasChange("package") {
newPackage := d.Get("package").(string) newPackage := d.Get("package").(string)
err := client.Machines().ResizeMachine(&triton.ResizeMachineInput{ err := client.Machines().ResizeMachine(context.Background(), &triton.ResizeMachineInput{
ID: d.Id(), ID: d.Id(),
Package: newPackage, Package: newPackage,
}) })
@ -457,7 +458,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{fmt.Sprintf("%s@%s", newPackage, "running")}, Target: []string{fmt.Sprintf("%s@%s", newPackage, "running")},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -482,11 +483,11 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
var err error var err error
if enable { if enable {
err = client.Machines().EnableMachineFirewall(&triton.EnableMachineFirewallInput{ err = client.Machines().EnableMachineFirewall(context.Background(), &triton.EnableMachineFirewallInput{
ID: d.Id(), ID: d.Id(),
}) })
} else { } else {
err = client.Machines().DisableMachineFirewall(&triton.DisableMachineFirewallInput{ err = client.Machines().DisableMachineFirewall(context.Background(), &triton.DisableMachineFirewallInput{
ID: d.Id(), ID: d.Id(),
}) })
} }
@ -497,7 +498,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{fmt.Sprintf("%t", enable)}, Target: []string{fmt.Sprintf("%t", enable)},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -531,7 +532,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
for _, nicI := range newNICs.Difference(oldNICs).List() { for _, nicI := range newNICs.Difference(oldNICs).List() {
nic := nicI.(map[string]interface{}) nic := nicI.(map[string]interface{})
if _, err := client.Machines().AddNIC(&triton.AddNICInput{ if _, err := client.Machines().AddNIC(context.Background(), &triton.AddNICInput{
MachineID: d.Id(), MachineID: d.Id(),
Network: nic["network"].(string), Network: nic["network"].(string),
}); err != nil { }); err != nil {
@ -541,7 +542,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
for _, nicI := range oldNICs.Difference(newNICs).List() { for _, nicI := range oldNICs.Difference(newNICs).List() {
nic := nicI.(map[string]interface{}) nic := nicI.(map[string]interface{})
if err := client.Machines().RemoveNIC(&triton.RemoveNICInput{ if err := client.Machines().RemoveNIC(context.Background(), &triton.RemoveNICInput{
MachineID: d.Id(), MachineID: d.Id(),
MAC: nic["mac"].(string), MAC: nic["mac"].(string),
}); err != nil { }); err != nil {
@ -559,7 +560,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
} }
} }
if len(metadata) > 0 { if len(metadata) > 0 {
if _, err := client.Machines().UpdateMachineMetadata(&triton.UpdateMachineMetadataInput{ if _, err := client.Machines().UpdateMachineMetadata(context.Background(), &triton.UpdateMachineMetadataInput{
ID: d.Id(), ID: d.Id(),
Metadata: metadata, Metadata: metadata,
}); err != nil { }); err != nil {
@ -569,7 +570,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{"converged"}, Target: []string{"converged"},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -607,7 +608,7 @@ func resourceMachineUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceMachineDelete(d *schema.ResourceData, meta interface{}) error { func resourceMachineDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
err := client.Machines().DeleteMachine(&triton.DeleteMachineInput{ err := client.Machines().DeleteMachine(context.Background(), &triton.DeleteMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {
@ -617,7 +618,7 @@ func resourceMachineDelete(d *schema.ResourceData, meta interface{}) error {
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
Target: []string{machineStateDeleted}, Target: []string{machineStateDeleted},
Refresh: func() (interface{}, string, error) { Refresh: func() (interface{}, string, error) {
getResp, err := client.Machines().GetMachine(&triton.GetMachineInput{ getResp, err := client.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: d.Id(), ID: d.Id(),
}) })
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"log" "log"
"regexp" "regexp"
@ -129,7 +130,7 @@ func testCheckTritonMachineExists(name string) resource.TestCheckFunc {
} }
conn := testAccProvider.Meta().(*triton.Client) conn := testAccProvider.Meta().(*triton.Client)
machine, err := conn.Machines().GetMachine(&triton.GetMachineInput{ machine, err := conn.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: rs.Primary.ID, ID: rs.Primary.ID,
}) })
if err != nil { if err != nil {
@ -158,7 +159,7 @@ func testCheckTritonMachineHasFabric(name, fabricName string) resource.TestCheck
} }
conn := testAccProvider.Meta().(*triton.Client) conn := testAccProvider.Meta().(*triton.Client)
nics, err := conn.Machines().ListNICs(&triton.ListNICsInput{ nics, err := conn.Machines().ListNICs(context.Background(), &triton.ListNICsInput{
MachineID: machine.Primary.ID, MachineID: machine.Primary.ID,
}) })
if err != nil { if err != nil {
@ -183,7 +184,7 @@ func testCheckTritonMachineDestroy(s *terraform.State) error {
continue continue
} }
resp, err := conn.Machines().GetMachine(&triton.GetMachineInput{ resp, err := conn.Machines().GetMachine(context.Background(), &triton.GetMachineInput{
ID: rs.Primary.ID, ID: rs.Primary.ID,
}) })
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"errors" "errors"
"strconv" "strconv"
@ -51,7 +52,7 @@ func resourceVLAN() *schema.Resource {
func resourceVLANCreate(d *schema.ResourceData, meta interface{}) error { func resourceVLANCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
vlan, err := client.Fabrics().CreateFabricVLAN(&triton.CreateFabricVLANInput{ vlan, err := client.Fabrics().CreateFabricVLAN(context.Background(), &triton.CreateFabricVLANInput{
ID: d.Get("vlan_id").(int), ID: d.Get("vlan_id").(int),
Name: d.Get("name").(string), Name: d.Get("name").(string),
Description: d.Get("description").(string), Description: d.Get("description").(string),
@ -72,7 +73,7 @@ func resourceVLANExists(d *schema.ResourceData, meta interface{}) (bool, error)
return false, err return false, err
} }
return resourceExists(client.Fabrics().GetFabricVLAN(&triton.GetFabricVLANInput{ return resourceExists(client.Fabrics().GetFabricVLAN(context.Background(), &triton.GetFabricVLANInput{
ID: id, ID: id,
})) }))
} }
@ -85,7 +86,7 @@ func resourceVLANRead(d *schema.ResourceData, meta interface{}) error {
return err return err
} }
vlan, err := client.Fabrics().GetFabricVLAN(&triton.GetFabricVLANInput{ vlan, err := client.Fabrics().GetFabricVLAN(context.Background(), &triton.GetFabricVLANInput{
ID: id, ID: id,
}) })
if err != nil { if err != nil {
@ -102,7 +103,7 @@ func resourceVLANRead(d *schema.ResourceData, meta interface{}) error {
func resourceVLANUpdate(d *schema.ResourceData, meta interface{}) error { func resourceVLANUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*triton.Client) client := meta.(*triton.Client)
vlan, err := client.Fabrics().UpdateFabricVLAN(&triton.UpdateFabricVLANInput{ vlan, err := client.Fabrics().UpdateFabricVLAN(context.Background(), &triton.UpdateFabricVLANInput{
ID: d.Get("vlan_id").(int), ID: d.Get("vlan_id").(int),
Name: d.Get("name").(string), Name: d.Get("name").(string),
Description: d.Get("description").(string), Description: d.Get("description").(string),
@ -123,7 +124,7 @@ func resourceVLANDelete(d *schema.ResourceData, meta interface{}) error {
return err return err
} }
return client.Fabrics().DeleteFabricVLAN(&triton.DeleteFabricVLANInput{ return client.Fabrics().DeleteFabricVLAN(context.Background(), &triton.DeleteFabricVLANInput{
ID: id, ID: id,
}) })
} }

View File

@ -1,6 +1,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
"testing" "testing"
@ -76,7 +77,7 @@ func testCheckTritonVLANExists(name string) resource.TestCheckFunc {
return err return err
} }
resp, err := conn.Fabrics().GetFabricVLAN(&triton.GetFabricVLANInput{ resp, err := conn.Fabrics().GetFabricVLAN(context.Background(), &triton.GetFabricVLANInput{
ID: id, ID: id,
}) })
if err != nil && triton.IsResourceNotFound(err) { if err != nil && triton.IsResourceNotFound(err) {
@ -106,7 +107,7 @@ func testCheckTritonVLANDestroy(s *terraform.State) error {
return err return err
} }
resp, err := conn.Fabrics().GetFabricVLAN(&triton.GetFabricVLANInput{ resp, err := conn.Fabrics().GetFabricVLAN(context.Background(), &triton.GetFabricVLANInput{
ID: id, ID: id,
}) })
if triton.IsResourceNotFound(err) { if triton.IsResourceNotFound(err) {