providers/cloudflare: tests passing, compiles

This commit is contained in:
Mitchell Hashimoto 2014-09-16 17:31:07 -07:00
parent e4066595c9
commit 78471d2aa0
3 changed files with 26 additions and 23 deletions

View File

@ -11,9 +11,9 @@ import (
) )
func resource_cloudflare_record_create( func resource_cloudflare_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
@ -51,9 +51,9 @@ func resource_cloudflare_record_create(
} }
func resource_cloudflare_record_update( func resource_cloudflare_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)
@ -86,7 +86,7 @@ func resource_cloudflare_record_update(
} }
func resource_cloudflare_record_destroy( func resource_cloudflare_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
@ -103,8 +103,8 @@ func resource_cloudflare_record_destroy(
} }
func resource_cloudflare_record_refresh( func resource_cloudflare_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
@ -117,7 +117,7 @@ func resource_cloudflare_record_refresh(
} }
func resource_cloudflare_record_diff( func resource_cloudflare_record_diff(
s *terraform.ResourceState, s *terraform.InstanceState,
c *terraform.ResourceConfig, c *terraform.ResourceConfig,
meta interface{}) (*terraform.ResourceDiff, error) { meta interface{}) (*terraform.ResourceDiff, error) {
@ -144,8 +144,8 @@ func resource_cloudflare_record_diff(
} }
func resource_cloudflare_record_update_state( func resource_cloudflare_record_update_state(
s *terraform.ResourceState, s *terraform.InstanceState,
rec *cloudflare.Record) (*terraform.ResourceState, error) { rec *cloudflare.Record) (*terraform.InstanceState, error) {
s.Attributes["name"] = rec.Name s.Attributes["name"] = rec.Name
s.Attributes["value"] = rec.Value s.Attributes["value"] = rec.Value

View File

@ -78,12 +78,12 @@ func TestAccCLOudflareRecord_Updated(t *testing.T) {
func testAccCheckCLOudflareRecordDestroy(s *terraform.State) error { func testAccCheckCLOudflareRecordDestroy(s *terraform.State) error {
client := testAccProvider.client client := testAccProvider.client
for _, rs := range s.Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "cloudflare_record" { if rs.Type != "cloudflare_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 testAccCheckCLOudflareRecordAttributesUpdated(record *cloudflare.Record) re
func testAccCheckCLOudflareRecordExists(n string, record *cloudflare.Record) resource.TestCheckFunc { func testAccCheckCLOudflareRecordExists(n string, record *cloudflare.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.Id != rs.ID { if foundRecord.Id != rs.Primary.ID {
return fmt.Errorf("Record not found") return fmt.Errorf("Record not found")
} }

View File

@ -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 {