providers/dnsimple: tests passing, compiling
This commit is contained in:
parent
a590ed02df
commit
c2a2aca999
|
@ -11,9 +11,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func resource_dnsimple_record_create(
|
func resource_dnsimple_record_create(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
d *terraform.ResourceDiff,
|
d *terraform.ResourceDiff,
|
||||||
meta interface{}) (*terraform.ResourceState, error) {
|
meta interface{}) (*terraform.InstanceState, error) {
|
||||||
p := meta.(*ResourceProvider)
|
p := meta.(*ResourceProvider)
|
||||||
client := p.client
|
client := p.client
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ func resource_dnsimple_record_create(
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_dnsimple_record_update(
|
func resource_dnsimple_record_update(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
d *terraform.ResourceDiff,
|
d *terraform.ResourceDiff,
|
||||||
meta interface{}) (*terraform.ResourceState, error) {
|
meta interface{}) (*terraform.InstanceState, error) {
|
||||||
p := meta.(*ResourceProvider)
|
p := meta.(*ResourceProvider)
|
||||||
client := p.client
|
client := p.client
|
||||||
rs := s.MergeDiff(d)
|
rs := s.MergeDiff(d)
|
||||||
|
@ -94,7 +94,7 @@ func resource_dnsimple_record_update(
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_dnsimple_record_destroy(
|
func resource_dnsimple_record_destroy(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
meta interface{}) error {
|
meta interface{}) error {
|
||||||
p := meta.(*ResourceProvider)
|
p := meta.(*ResourceProvider)
|
||||||
client := p.client
|
client := p.client
|
||||||
|
@ -111,8 +111,8 @@ func resource_dnsimple_record_destroy(
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_dnsimple_record_refresh(
|
func resource_dnsimple_record_refresh(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
meta interface{}) (*terraform.ResourceState, error) {
|
meta interface{}) (*terraform.InstanceState, error) {
|
||||||
p := meta.(*ResourceProvider)
|
p := meta.(*ResourceProvider)
|
||||||
client := p.client
|
client := p.client
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ func resource_dnsimple_record_refresh(
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_dnsimple_record_diff(
|
func resource_dnsimple_record_diff(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
c *terraform.ResourceConfig,
|
c *terraform.ResourceConfig,
|
||||||
meta interface{}) (*terraform.ResourceDiff, error) {
|
meta interface{}) (*terraform.ResourceDiff, error) {
|
||||||
|
|
||||||
|
@ -153,8 +153,8 @@ func resource_dnsimple_record_diff(
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_dnsimple_record_update_state(
|
func resource_dnsimple_record_update_state(
|
||||||
s *terraform.ResourceState,
|
s *terraform.InstanceState,
|
||||||
rec *dnsimple.Record) (*terraform.ResourceState, error) {
|
rec *dnsimple.Record) (*terraform.InstanceState, error) {
|
||||||
|
|
||||||
s.Attributes["name"] = rec.Name
|
s.Attributes["name"] = rec.Name
|
||||||
s.Attributes["value"] = rec.Content
|
s.Attributes["value"] = rec.Content
|
||||||
|
|
|
@ -78,12 +78,12 @@ func TestAccDNSimpleRecord_Updated(t *testing.T) {
|
||||||
func testAccCheckDNSimpleRecordDestroy(s *terraform.State) error {
|
func testAccCheckDNSimpleRecordDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.client
|
client := testAccProvider.client
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "dnsimple_record" {
|
if rs.Type != "dnsimple_record" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := client.RetrieveRecord(rs.Attributes["domain"], rs.ID)
|
_, err := client.RetrieveRecord(rs.Primary.Attributes["domain"], rs.Primary.ID)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Record still exists")
|
return fmt.Errorf("Record still exists")
|
||||||
|
@ -117,25 +117,25 @@ func testAccCheckDNSimpleRecordAttributesUpdated(record *dnsimple.Record) resour
|
||||||
|
|
||||||
func testAccCheckDNSimpleRecordExists(n string, record *dnsimple.Record) resource.TestCheckFunc {
|
func testAccCheckDNSimpleRecordExists(n string, record *dnsimple.Record) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No Record ID is set")
|
return fmt.Errorf("No Record ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
client := testAccProvider.client
|
client := testAccProvider.client
|
||||||
|
|
||||||
foundRecord, err := client.RetrieveRecord(rs.Attributes["domain"], rs.ID)
|
foundRecord, err := client.RetrieveRecord(rs.Primary.Attributes["domain"], rs.Primary.ID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundRecord.StringId() != rs.ID {
|
if foundRecord.StringId() != rs.Primary.ID {
|
||||||
return fmt.Errorf("Record not found")
|
return fmt.Errorf("Record not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,20 +47,23 @@ func (p *ResourceProvider) Configure(c *terraform.ResourceConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ResourceProvider) Apply(
|
func (p *ResourceProvider) Apply(
|
||||||
s *terraform.ResourceState,
|
info *terraform.InstanceInfo,
|
||||||
d *terraform.ResourceDiff) (*terraform.ResourceState, error) {
|
s *terraform.InstanceState,
|
||||||
return resourceMap.Apply(s, d, p)
|
d *terraform.ResourceDiff) (*terraform.InstanceState, error) {
|
||||||
|
return resourceMap.Apply(info, s, d, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ResourceProvider) Diff(
|
func (p *ResourceProvider) Diff(
|
||||||
s *terraform.ResourceState,
|
info *terraform.InstanceInfo,
|
||||||
|
s *terraform.InstanceState,
|
||||||
c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
|
c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
|
||||||
return resourceMap.Diff(s, c, p)
|
return resourceMap.Diff(info, s, c, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ResourceProvider) Refresh(
|
func (p *ResourceProvider) Refresh(
|
||||||
s *terraform.ResourceState) (*terraform.ResourceState, error) {
|
info *terraform.InstanceInfo,
|
||||||
return resourceMap.Refresh(s, p)
|
s *terraform.InstanceState) (*terraform.InstanceState, error) {
|
||||||
|
return resourceMap.Refresh(info, s, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ResourceProvider) Resources() []terraform.ResourceType {
|
func (p *ResourceProvider) Resources() []terraform.ResourceType {
|
||||||
|
|
Loading…
Reference in New Issue