rpc: conform to new types

This commit is contained in:
Mitchell Hashimoto 2014-06-12 18:06:26 -07:00
parent 7e421dd89b
commit f15746f692
2 changed files with 19 additions and 9 deletions

View File

@ -13,7 +13,7 @@ type ResourceProvider struct {
Name string Name string
} }
func (p *ResourceProvider) Configure(c map[string]interface{}) error { func (p *ResourceProvider) Configure(c *terraform.ResourceConfig) error {
var resp ResourceProviderConfigureResponse var resp ResourceProviderConfigureResponse
err := p.Client.Call(p.Name+".Configure", c, &resp) err := p.Client.Call(p.Name+".Configure", c, &resp)
if err != nil { if err != nil {
@ -28,7 +28,7 @@ func (p *ResourceProvider) Configure(c map[string]interface{}) error {
func (p *ResourceProvider) Diff( func (p *ResourceProvider) Diff(
s *terraform.ResourceState, s *terraform.ResourceState,
c map[string]interface{}) (*terraform.ResourceDiff, error) { c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
var resp ResourceProviderDiffResponse var resp ResourceProviderDiffResponse
args := &ResourceProviderDiffArgs{ args := &ResourceProviderDiffArgs{
State: s, State: s,
@ -69,7 +69,7 @@ type ResourceProviderConfigureResponse struct {
type ResourceProviderDiffArgs struct { type ResourceProviderDiffArgs struct {
State *terraform.ResourceState State *terraform.ResourceState
Config map[string]interface{} Config *terraform.ResourceConfig
} }
type ResourceProviderDiffResponse struct { type ResourceProviderDiffResponse struct {
@ -78,7 +78,7 @@ type ResourceProviderDiffResponse struct {
} }
func (s *ResourceProviderServer) Configure( func (s *ResourceProviderServer) Configure(
config map[string]interface{}, config *terraform.ResourceConfig,
reply *ResourceProviderConfigureResponse) error { reply *ResourceProviderConfigureResponse) error {
err := s.Provider.Configure(config) err := s.Provider.Configure(config)
*reply = ResourceProviderConfigureResponse{ *reply = ResourceProviderConfigureResponse{

View File

@ -18,7 +18,9 @@ func TestResourceProvider_configure(t *testing.T) {
provider := &ResourceProvider{Client: client, Name: name} provider := &ResourceProvider{Client: client, Name: name}
// Configure // Configure
config := map[string]interface{}{"foo": "bar"} config := &terraform.ResourceConfig{
Raw: map[string]interface{}{"foo": "bar"},
}
e := provider.Configure(config) e := provider.Configure(config)
if !p.ConfigureCalled { if !p.ConfigureCalled {
t.Fatal("configure should be called") t.Fatal("configure should be called")
@ -43,7 +45,9 @@ func TestResourceProvider_configure_errors(t *testing.T) {
p.ConfigureReturnError = errors.New("foo") p.ConfigureReturnError = errors.New("foo")
// Configure // Configure
config := map[string]interface{}{"foo": "bar"} config := &terraform.ResourceConfig{
Raw: map[string]interface{}{"foo": "bar"},
}
e := provider.Configure(config) e := provider.Configure(config)
if !p.ConfigureCalled { if !p.ConfigureCalled {
t.Fatal("configure should be called") t.Fatal("configure should be called")
@ -69,7 +73,9 @@ func TestResourceProvider_configure_warnings(t *testing.T) {
provider := &ResourceProvider{Client: client, Name: name} provider := &ResourceProvider{Client: client, Name: name}
// Configure // Configure
config := map[string]interface{}{"foo": "bar"} config := &terraform.ResourceConfig{
Raw: map[string]interface{}{"foo": "bar"},
}
e := provider.Configure(config) e := provider.Configure(config)
if !p.ConfigureCalled { if !p.ConfigureCalled {
t.Fatal("configure should be called") t.Fatal("configure should be called")
@ -102,7 +108,9 @@ func TestResourceProvider_diff(t *testing.T) {
// Diff // Diff
state := &terraform.ResourceState{} state := &terraform.ResourceState{}
config := map[string]interface{}{"foo": "bar"} config := &terraform.ResourceConfig{
Raw: map[string]interface{}{"foo": "bar"},
}
diff, err := provider.Diff(state, config) diff, err := provider.Diff(state, config)
if !p.DiffCalled { if !p.DiffCalled {
t.Fatal("diff should be called") t.Fatal("diff should be called")
@ -131,7 +139,9 @@ func TestResourceProvider_diff_error(t *testing.T) {
// Diff // Diff
state := &terraform.ResourceState{} state := &terraform.ResourceState{}
config := map[string]interface{}{"foo": "bar"} config := &terraform.ResourceConfig{
Raw: map[string]interface{}{"foo": "bar"},
}
diff, err := provider.Diff(state, config) diff, err := provider.Diff(state, config)
if !p.DiffCalled { if !p.DiffCalled {
t.Fatal("diff should be called") t.Fatal("diff should be called")