rpc: fix interface impl

This commit is contained in:
Mitchell Hashimoto 2014-07-22 10:36:37 -07:00
parent 10a86c6ef7
commit 53ebc5cb51
2 changed files with 5 additions and 14 deletions

View File

@ -37,7 +37,7 @@ func (p *ResourceProvisioner) Validate(c *terraform.ResourceConfig) ([]string, [
func (p *ResourceProvisioner) Apply( func (p *ResourceProvisioner) Apply(
s *terraform.ResourceState, s *terraform.ResourceState,
c *terraform.ResourceConfig) (*terraform.ResourceState, error) { c *terraform.ResourceConfig) error {
var resp ResourceProvisionerApplyResponse var resp ResourceProvisionerApplyResponse
args := &ResourceProvisionerApplyArgs{ args := &ResourceProvisionerApplyArgs{
State: s, State: s,
@ -46,13 +46,13 @@ func (p *ResourceProvisioner) Apply(
err := p.Client.Call(p.Name+".Apply", args, &resp) err := p.Client.Call(p.Name+".Apply", args, &resp)
if err != nil { if err != nil {
return nil, err return err
} }
if resp.Error != nil { if resp.Error != nil {
err = resp.Error err = resp.Error
} }
return resp.State, err return err
} }
type ResourceProvisionerValidateArgs struct { type ResourceProvisionerValidateArgs struct {
@ -70,7 +70,6 @@ type ResourceProvisionerApplyArgs struct {
} }
type ResourceProvisionerApplyResponse struct { type ResourceProvisionerApplyResponse struct {
State *terraform.ResourceState
Error *BasicError Error *BasicError
} }
@ -83,9 +82,8 @@ type ResourceProvisionerServer struct {
func (s *ResourceProvisionerServer) Apply( func (s *ResourceProvisionerServer) Apply(
args *ResourceProvisionerApplyArgs, args *ResourceProvisionerApplyArgs,
result *ResourceProvisionerApplyResponse) error { result *ResourceProvisionerApplyResponse) error {
state, err := s.Provisioner.Apply(args.State, args.Config) err := s.Provisioner.Apply(args.State, args.Config)
*result = ResourceProvisionerApplyResponse{ *result = ResourceProvisionerApplyResponse{
State: state,
Error: NewBasicError(err), Error: NewBasicError(err),
} }
return nil return nil

View File

@ -21,14 +21,10 @@ func TestResourceProvisioner_apply(t *testing.T) {
} }
provisioner := &ResourceProvisioner{Client: client, Name: name} provisioner := &ResourceProvisioner{Client: client, Name: name}
p.ApplyReturn = &terraform.ResourceState{
ID: "bob",
}
// Apply // Apply
state := &terraform.ResourceState{} state := &terraform.ResourceState{}
conf := &terraform.ResourceConfig{} conf := &terraform.ResourceConfig{}
newState, err := provisioner.Apply(state, conf) err = provisioner.Apply(state, conf)
if !p.ApplyCalled { if !p.ApplyCalled {
t.Fatal("apply should be called") t.Fatal("apply should be called")
} }
@ -38,9 +34,6 @@ func TestResourceProvisioner_apply(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("bad: %#v", err) t.Fatalf("bad: %#v", err)
} }
if !reflect.DeepEqual(p.ApplyReturn, newState) {
t.Fatalf("bad: %#v", newState)
}
} }
func TestResourceProvisioner_validate(t *testing.T) { func TestResourceProvisioner_validate(t *testing.T) {