mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
![Riley Karson](/assets/img/avatar_default.png)
```bash GO111MODULE=on go get github.com/hashicorp/terraform@pluginsdk-v0.12-early7 GO111MODULE=on go mod vendor GO111MODULE=on go mod tidy ```
36 lines
959 B
Go
36 lines
959 B
Go
package plugin
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
"github.com/hashicorp/terraform/plugin/discovery"
|
|
)
|
|
|
|
// ClientConfig returns a configuration object that can be used to instantiate
|
|
// a client for the plugin described by the given metadata.
|
|
func ClientConfig(m discovery.PluginMeta) *plugin.ClientConfig {
|
|
logger := hclog.New(&hclog.LoggerOptions{
|
|
Name: "plugin",
|
|
Level: hclog.Trace,
|
|
Output: os.Stderr,
|
|
})
|
|
|
|
return &plugin.ClientConfig{
|
|
Cmd: exec.Command(m.Path),
|
|
HandshakeConfig: Handshake,
|
|
VersionedPlugins: VersionedPlugins,
|
|
Managed: true,
|
|
Logger: logger,
|
|
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
|
|
AutoMTLS: true,
|
|
}
|
|
}
|
|
|
|
// Client returns a plugin client for the plugin described by the given metadata.
|
|
func Client(m discovery.PluginMeta) *plugin.Client {
|
|
return plugin.NewClient(ClientConfig(m))
|
|
}
|