add grpc shims to helper/plugin
Add shim functions to automatically wrap plugins in the new GRPC implementations.
This commit is contained in:
parent
5e7956f440
commit
7188d5cbfe
|
@ -16,6 +16,20 @@ import (
|
||||||
"github.com/zclconf/go-cty/cty/msgpack"
|
"github.com/zclconf/go-cty/cty/msgpack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewGRPCProviderServerShim wraps a terraform.ResourceProvider in a
|
||||||
|
// proto.ProviderServer implementation. If the provided provider is not a
|
||||||
|
// *schema.Provider, this will return nil,
|
||||||
|
func NewGRPCProviderServerShim(p terraform.ResourceProvider) *GRPCProviderServer {
|
||||||
|
sp, ok := p.(*schema.Provider)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &GRPCProviderServer{
|
||||||
|
provider: sp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GRPCProviderServer handles the server, or plugin side of the rpc connection.
|
// GRPCProviderServer handles the server, or plugin side of the rpc connection.
|
||||||
type GRPCProviderServer struct {
|
type GRPCProviderServer struct {
|
||||||
provider *schema.Provider
|
provider *schema.Provider
|
||||||
|
|
|
@ -12,6 +12,19 @@ import (
|
||||||
context "golang.org/x/net/context"
|
context "golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewGRPCProvisionerServerShim wraps a terraform.ResourceProvisioner in a
|
||||||
|
// proto.ProvisionerServer implementation. If the provided provisioner is not a
|
||||||
|
// *schema.Provisioner, this will return nil,
|
||||||
|
func NewGRPCProvisionerServerShim(p terraform.ResourceProvisioner) *GRPCProvisionerServer {
|
||||||
|
sp, ok := p.(*schema.Provisioner)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &GRPCProvisionerServer{
|
||||||
|
provisioner: sp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type GRPCProvisionerServer struct {
|
type GRPCProvisionerServer struct {
|
||||||
provisioner *schema.Provisioner
|
provisioner *schema.Provisioner
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue