providers/consul: tests passing, compiling

This commit is contained in:
Mitchell Hashimoto 2014-09-16 17:29:38 -07:00
parent aafbc2ab7c
commit e4066595c9
3 changed files with 21 additions and 18 deletions

View File

@ -27,16 +27,16 @@ func resource_consul_keys_validation() *config.Validator {
}
}
func resource_consul_keys_update(
s *terraform.ResourceState,
s *terraform.InstanceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
meta interface{}) (*terraform.InstanceState, error) {
return resource_consul_keys_create(s, d, meta)
}
func resource_consul_keys_create(
s *terraform.ResourceState,
s *terraform.InstanceState,
d *terraform.ResourceDiff,
meta interface{}) (*terraform.ResourceState, error) {
meta interface{}) (*terraform.InstanceState, error) {
p := meta.(*ResourceProvider)
// Merge the diff into the state so that we have all the attributes
@ -97,7 +97,7 @@ func resource_consul_keys_create(
}
func resource_consul_keys_destroy(
s *terraform.ResourceState,
s *terraform.InstanceState,
meta interface{}) error {
p := meta.(*ResourceProvider)
client := p.client
@ -132,7 +132,7 @@ func resource_consul_keys_destroy(
}
func resource_consul_keys_diff(
s *terraform.ResourceState,
s *terraform.InstanceState,
c *terraform.ResourceConfig,
meta interface{}) (*terraform.ResourceDiff, error) {
@ -162,8 +162,8 @@ AFTER:
}
func resource_consul_keys_refresh(
s *terraform.ResourceState,
meta interface{}) (*terraform.ResourceState, error) {
s *terraform.InstanceState,
meta interface{}) (*terraform.InstanceState, error) {
p := meta.(*ResourceProvider)
client := p.client
kv := client.KV()

View File

@ -58,13 +58,13 @@ func testAccCheckConsulKeysExists() resource.TestCheckFunc {
func testAccCheckConsulKeysValue(n, attr, val string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rn, ok := s.Resources[n]
rn, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Resource not found")
}
out, ok := rn.Attributes["var."+attr]
out, ok := rn.Primary.Attributes["var."+attr]
if !ok {
return fmt.Errorf("Attribute '%s' not found: %#v", attr, rn.Attributes)
return fmt.Errorf("Attribute '%s' not found: %#v", attr, rn.Primary.Attributes)
}
if val != "<any>" && out != val {
return fmt.Errorf("Attribute '%s' value '%s' != '%s'", attr, out, val)

View File

@ -43,20 +43,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 {