providers/cloudflare: tests passing, compiles
This commit is contained in:
parent
e4066595c9
commit
78471d2aa0
|
@ -11,9 +11,9 @@ import (
|
|||
)
|
||||
|
||||
func resource_cloudflare_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
|
||||
|
||||
|
@ -51,9 +51,9 @@ func resource_cloudflare_record_create(
|
|||
}
|
||||
|
||||
func resource_cloudflare_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)
|
||||
|
@ -86,7 +86,7 @@ func resource_cloudflare_record_update(
|
|||
}
|
||||
|
||||
func resource_cloudflare_record_destroy(
|
||||
s *terraform.ResourceState,
|
||||
s *terraform.InstanceState,
|
||||
meta interface{}) error {
|
||||
p := meta.(*ResourceProvider)
|
||||
client := p.client
|
||||
|
@ -103,8 +103,8 @@ func resource_cloudflare_record_destroy(
|
|||
}
|
||||
|
||||
func resource_cloudflare_record_refresh(
|
||||
s *terraform.ResourceState,
|
||||
meta interface{}) (*terraform.ResourceState, error) {
|
||||
s *terraform.InstanceState,
|
||||
meta interface{}) (*terraform.InstanceState, error) {
|
||||
p := meta.(*ResourceProvider)
|
||||
client := p.client
|
||||
|
||||
|
@ -117,7 +117,7 @@ func resource_cloudflare_record_refresh(
|
|||
}
|
||||
|
||||
func resource_cloudflare_record_diff(
|
||||
s *terraform.ResourceState,
|
||||
s *terraform.InstanceState,
|
||||
c *terraform.ResourceConfig,
|
||||
meta interface{}) (*terraform.ResourceDiff, error) {
|
||||
|
||||
|
@ -144,8 +144,8 @@ func resource_cloudflare_record_diff(
|
|||
}
|
||||
|
||||
func resource_cloudflare_record_update_state(
|
||||
s *terraform.ResourceState,
|
||||
rec *cloudflare.Record) (*terraform.ResourceState, error) {
|
||||
s *terraform.InstanceState,
|
||||
rec *cloudflare.Record) (*terraform.InstanceState, error) {
|
||||
|
||||
s.Attributes["name"] = rec.Name
|
||||
s.Attributes["value"] = rec.Value
|
||||
|
|
|
@ -78,12 +78,12 @@ func TestAccCLOudflareRecord_Updated(t *testing.T) {
|
|||
func testAccCheckCLOudflareRecordDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.client
|
||||
|
||||
for _, rs := range s.Resources {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "cloudflare_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 testAccCheckCLOudflareRecordAttributesUpdated(record *cloudflare.Record) re
|
|||
|
||||
func testAccCheckCLOudflareRecordExists(n string, record *cloudflare.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.Id != rs.ID {
|
||||
if foundRecord.Id != rs.Primary.ID {
|
||||
return fmt.Errorf("Record not found")
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue