provider/triton: add machine domain names (#7149)
* vendor joyent/gosdc/cloudapi * provider/triton: Add machine domain names - Includes acceptance test.
This commit is contained in:
parent
81814c7997
commit
80936e3562
|
@ -167,6 +167,14 @@ func resourceMachine() *schema.Resource {
|
|||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"domain_names": {
|
||||
Description: "list of domain names from Triton's CNS",
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
|
||||
// computed resources from metadata
|
||||
"root_authorized_keys": {
|
||||
|
@ -298,6 +306,7 @@ func resourceMachineRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("image", machine.Image)
|
||||
d.Set("primaryip", machine.PrimaryIP)
|
||||
d.Set("firewall_enabled", machine.FirewallEnabled)
|
||||
d.Set("domain_names", machine.DomainNames)
|
||||
|
||||
// create and update NICs
|
||||
var (
|
||||
|
|
|
@ -2,6 +2,7 @@ package triton
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -34,6 +35,35 @@ func TestAccTritonMachine_basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccTritonMachine_dns(t *testing.T) {
|
||||
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
||||
dns_output := fmt.Sprintf(testAccTritonMachine_dns, machineName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckTritonMachineDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: dns_output,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckTritonMachineExists("triton_machine.test"),
|
||||
func(*terraform.State) error {
|
||||
time.Sleep(10 * time.Second)
|
||||
return nil
|
||||
},
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: dns_output,
|
||||
Check: resource.TestMatchOutput(
|
||||
"domain_names", regexp.MustCompile(".*acctest-.*"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccTritonMachine_nic(t *testing.T) {
|
||||
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
||||
config := fmt.Sprintf(testAccTritonMachine_withnic, machineName, machineName)
|
||||
|
@ -369,3 +399,17 @@ resource "triton_machine" "test" {
|
|||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccTritonMachine_dns = `
|
||||
provider "triton" {
|
||||
}
|
||||
|
||||
resource "triton_machine" "test" {
|
||||
name = "%s"
|
||||
package = "g4-highcpu-128M"
|
||||
image = "e1faace4-e19b-11e5-928b-83849e2fd94a"
|
||||
}
|
||||
output "domain_names" {
|
||||
value = "${join(", ", triton_machine.test.domain_names)}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -600,6 +600,26 @@ func TestCheckOutput(name, value string) TestCheckFunc {
|
|||
}
|
||||
}
|
||||
|
||||
func TestMatchOutput(name string, r *regexp.Regexp) TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
ms := s.RootModule()
|
||||
rs, ok := ms.Outputs[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
if !r.MatchString(rs.Value.(string)) {
|
||||
return fmt.Errorf(
|
||||
"Output '%s': %#v didn't match %q",
|
||||
name,
|
||||
rs,
|
||||
r.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// TestT is the interface used to handle the test lifecycle of a test.
|
||||
//
|
||||
// Users should just use a *testing.T object, which implements this.
|
||||
|
|
|
@ -30,6 +30,7 @@ type Machine struct {
|
|||
PrimaryIP string // The primary (public) IP address for the machine
|
||||
Networks []string // The network IDs for the machine
|
||||
FirewallEnabled bool `json:"firewall_enabled"` // whether or not the firewall is enabled
|
||||
DomainNames []string `json:"dns_names"` // The domain names of this machine
|
||||
}
|
||||
|
||||
// Equals compares two machines. Ignores state and timestamps.
|
||||
|
|
|
@ -950,8 +950,10 @@
|
|||
"revision": "ade826b8b54e81a779ccb29d358a45ba24b7809c"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "PDzjpRNeytdYU39/PByzwCMvKQ8=",
|
||||
"path": "github.com/joyent/gosdc/cloudapi",
|
||||
"revision": "0697a5c4f39a71a4f9e3b154380b47dbfcc3da6e"
|
||||
"revision": "042c6e9de2b48a646d310e70cc0050c83fe18200",
|
||||
"revisionTime": "2016-04-26T05:09:12Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "N0NRIcJF7aj1wd56DA1N9GpYq/4=",
|
||||
|
|
Loading…
Reference in New Issue