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

View File

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