From f15746f692e5f72e635844a1771a5cfc4187c4b3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 12 Jun 2014 18:06:26 -0700 Subject: [PATCH] rpc: conform to new types --- rpc/resource_provider.go | 8 ++++---- rpc/resource_provider_test.go | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/rpc/resource_provider.go b/rpc/resource_provider.go index ffa1d3e1b..c7e19237c 100644 --- a/rpc/resource_provider.go +++ b/rpc/resource_provider.go @@ -13,7 +13,7 @@ type ResourceProvider struct { Name string } -func (p *ResourceProvider) Configure(c map[string]interface{}) error { +func (p *ResourceProvider) Configure(c *terraform.ResourceConfig) error { var resp ResourceProviderConfigureResponse err := p.Client.Call(p.Name+".Configure", c, &resp) if err != nil { @@ -28,7 +28,7 @@ func (p *ResourceProvider) Configure(c map[string]interface{}) error { func (p *ResourceProvider) Diff( s *terraform.ResourceState, - c map[string]interface{}) (*terraform.ResourceDiff, error) { + c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) { var resp ResourceProviderDiffResponse args := &ResourceProviderDiffArgs{ State: s, @@ -69,7 +69,7 @@ type ResourceProviderConfigureResponse struct { type ResourceProviderDiffArgs struct { State *terraform.ResourceState - Config map[string]interface{} + Config *terraform.ResourceConfig } type ResourceProviderDiffResponse struct { @@ -78,7 +78,7 @@ type ResourceProviderDiffResponse struct { } func (s *ResourceProviderServer) Configure( - config map[string]interface{}, + config *terraform.ResourceConfig, reply *ResourceProviderConfigureResponse) error { err := s.Provider.Configure(config) *reply = ResourceProviderConfigureResponse{ diff --git a/rpc/resource_provider_test.go b/rpc/resource_provider_test.go index 7f86b7601..7d25ac807 100644 --- a/rpc/resource_provider_test.go +++ b/rpc/resource_provider_test.go @@ -18,7 +18,9 @@ func TestResourceProvider_configure(t *testing.T) { provider := &ResourceProvider{Client: client, Name: name} // Configure - config := map[string]interface{}{"foo": "bar"} + config := &terraform.ResourceConfig{ + Raw: map[string]interface{}{"foo": "bar"}, + } e := provider.Configure(config) if !p.ConfigureCalled { t.Fatal("configure should be called") @@ -43,7 +45,9 @@ func TestResourceProvider_configure_errors(t *testing.T) { p.ConfigureReturnError = errors.New("foo") // Configure - config := map[string]interface{}{"foo": "bar"} + config := &terraform.ResourceConfig{ + Raw: map[string]interface{}{"foo": "bar"}, + } e := provider.Configure(config) if !p.ConfigureCalled { t.Fatal("configure should be called") @@ -69,7 +73,9 @@ func TestResourceProvider_configure_warnings(t *testing.T) { provider := &ResourceProvider{Client: client, Name: name} // Configure - config := map[string]interface{}{"foo": "bar"} + config := &terraform.ResourceConfig{ + Raw: map[string]interface{}{"foo": "bar"}, + } e := provider.Configure(config) if !p.ConfigureCalled { t.Fatal("configure should be called") @@ -102,7 +108,9 @@ func TestResourceProvider_diff(t *testing.T) { // Diff state := &terraform.ResourceState{} - config := map[string]interface{}{"foo": "bar"} + config := &terraform.ResourceConfig{ + Raw: map[string]interface{}{"foo": "bar"}, + } diff, err := provider.Diff(state, config) if !p.DiffCalled { t.Fatal("diff should be called") @@ -131,7 +139,9 @@ func TestResourceProvider_diff_error(t *testing.T) { // Diff state := &terraform.ResourceState{} - config := map[string]interface{}{"foo": "bar"} + config := &terraform.ResourceConfig{ + Raw: map[string]interface{}{"foo": "bar"}, + } diff, err := provider.Diff(state, config) if !p.DiffCalled { t.Fatal("diff should be called")