@@ -2,30 +2,35 @@ package instance
22
33import (
44 "encoding/json"
5+
6+ "github.com/docker/infrakit/pkg/plugin"
57 rpc_client "github.com/docker/infrakit/pkg/rpc/client"
68 "github.com/docker/infrakit/pkg/spi/instance"
79)
810
911// NewClient returns a plugin interface implementation connected to a plugin
10- func NewClient (socketPath string ) instance.Plugin {
11- return & client {client : rpc_client .New (socketPath , instance .InterfaceSpec )}
12+ func NewClient (name plugin. Name , socketPath string ) instance.Plugin {
13+ return & client {name : name , client : rpc_client .New (socketPath , instance .InterfaceSpec )}
1214}
1315
1416type client struct {
17+ name plugin.Name
1518 client rpc_client.Client
1619}
1720
1821// Validate performs local validation on a provision request.
1922func (c client ) Validate (properties json.RawMessage ) error {
20- req := ValidateRequest {Properties : & properties }
23+ _ , instanceType := c .name .GetLookupAndType ()
24+ req := ValidateRequest {Properties : & properties , Type : instanceType }
2125 resp := ValidateResponse {}
2226
2327 return c .client .Call ("Instance.Validate" , req , & resp )
2428}
2529
2630// Provision creates a new instance based on the spec.
2731func (c client ) Provision (spec instance.Spec ) (* instance.ID , error ) {
28- req := ProvisionRequest {Spec : spec }
32+ _ , instanceType := c .name .GetLookupAndType ()
33+ req := ProvisionRequest {Spec : spec , Type : instanceType }
2934 resp := ProvisionResponse {}
3035
3136 if err := c .client .Call ("Instance.Provision" , req , & resp ); err != nil {
@@ -37,15 +42,17 @@ func (c client) Provision(spec instance.Spec) (*instance.ID, error) {
3742
3843// Destroy terminates an existing instance.
3944func (c client ) Destroy (instance instance.ID ) error {
40- req := DestroyRequest {Instance : instance }
45+ _ , instanceType := c .name .GetLookupAndType ()
46+ req := DestroyRequest {Instance : instance , Type : instanceType }
4147 resp := DestroyResponse {}
4248
4349 return c .client .Call ("Instance.Destroy" , req , & resp )
4450}
4551
4652// DescribeInstances returns descriptions of all instances matching all of the provided tags.
4753func (c client ) DescribeInstances (tags map [string ]string ) ([]instance.Description , error ) {
48- req := DescribeInstancesRequest {Tags : tags }
54+ _ , instanceType := c .name .GetLookupAndType ()
55+ req := DescribeInstancesRequest {Tags : tags , Type : instanceType }
4956 resp := DescribeInstancesResponse {}
5057
5158 err := c .client .Call ("Instance.DescribeInstances" , req , & resp )
0 commit comments