providers/dnsimple: tests passing, compiling

This commit is contained in:
Mitchell Hashimoto 2014-09-16 17:24:05 -07:00
parent a590ed02df
commit c2a2aca999
3 changed files with 26 additions and 23 deletions

View File

@ -11,9 +11,9 @@ import (
)
func resource_dnsimple_record_create(
s *terraform.ResourceState,
s *terraform.InstanceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
meta interface{}) (*terraform.InstanceState, error) {
p := meta.(*ResourceProvider)
client := p.client
@ -53,9 +53,9 @@ func resource_dnsimple_record_create(
}
func resource_dnsimple_record_update(
s *terraform.ResourceState,
s *terraform.InstanceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
meta interface{}) (*terraform.InstanceState, error) {
p := meta.(*ResourceProvider)
client := p.client
rs := s.MergeDiff(d)
@ -94,7 +94,7 @@ func resource_dnsimple_record_update(
}
func resource_dnsimple_record_destroy(
s *terraform.ResourceState,
s *terraform.InstanceState,
meta interface{}) error {
p := meta.(*ResourceProvider)
client := p.client
@ -111,8 +111,8 @@ func resource_dnsimple_record_destroy(
}
func resource_dnsimple_record_refresh(
s *terraform.ResourceState,
meta interface{}) (*terraform.ResourceState, error) {
s *terraform.InstanceState,
meta interface{}) (*terraform.InstanceState, error) {
p := meta.(*ResourceProvider)
client := p.client
@ -125,7 +125,7 @@ func resource_dnsimple_record_refresh(
}
func resource_dnsimple_record_diff(
s *terraform.ResourceState,
s *terraform.InstanceState,
c *terraform.ResourceConfig,
meta interface{}) (*terraform.ResourceDiff, error) {
@ -153,8 +153,8 @@ func resource_dnsimple_record_diff(
}
func resource_dnsimple_record_update_state(
s *terraform.ResourceState,
rec *dnsimple.Record) (*terraform.ResourceState, error) {
s *terraform.InstanceState,
rec *dnsimple.Record) (*terraform.InstanceState, error) {
s.Attributes["name"] = rec.Name
s.Attributes["value"] = rec.Content

View File

@ -78,12 +78,12 @@ func TestAccDNSimpleRecord_Updated(t *testing.T) {
func testAccCheckDNSimpleRecordDestroy(s *terraform.State) error {
client := testAccProvider.client
for _, rs := range s.Resources {
for _, rs := range s.RootModule().Resources {
if rs.Type != "dnsimple_record" {
continue
}
_, err := client.RetrieveRecord(rs.Attributes["domain"], rs.ID)
_, err := client.RetrieveRecord(rs.Primary.Attributes["domain"], rs.Primary.ID)
if err == nil {
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 {
return func(s *terraform.State) error {
rs, ok := s.Resources[n]
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.ID == "" {
if rs.Primary.ID == "" {
return fmt.Errorf("No Record ID is set")
}
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 {
return err
}
if foundRecord.StringId() != rs.ID {
if foundRecord.StringId() != rs.Primary.ID {
return fmt.Errorf("Record not found")
}

View File

@ -47,20 +47,23 @@ func (p *ResourceProvider) Configure(c *terraform.ResourceConfig) error {
}
func (p *ResourceProvider) Apply(
s *terraform.ResourceState,
d *terraform.ResourceDiff) (*terraform.ResourceState, error) {
return resourceMap.Apply(s, d, p)
info *terraform.InstanceInfo,
s *terraform.InstanceState,
d *terraform.ResourceDiff) (*terraform.InstanceState, error) {
return resourceMap.Apply(info, s, d, p)
}
func (p *ResourceProvider) Diff(
s *terraform.ResourceState,
info *terraform.InstanceInfo,
s *terraform.InstanceState,
c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
return resourceMap.Diff(s, c, p)
return resourceMap.Diff(info, s, c, p)
}
func (p *ResourceProvider) Refresh(
s *terraform.ResourceState) (*terraform.ResourceState, error) {
return resourceMap.Refresh(s, p)
info *terraform.InstanceInfo,
s *terraform.InstanceState) (*terraform.InstanceState, error) {
return resourceMap.Refresh(info, s, p)
}
func (p *ResourceProvider) Resources() []terraform.ResourceType {