]>
Commit | Line | Data |
---|---|---|
c680a8e1 RS |
1 | package plugin |
2 | ||
3 | import ( | |
4 | "os/exec" | |
5 | ||
6 | plugin "github.com/hashicorp/go-plugin" | |
7 | "github.com/hashicorp/terraform/plugin/discovery" | |
8 | ) | |
9 | ||
10 | // ClientConfig returns a configuration object that can be used to instantiate | |
11 | // a client for the plugin described by the given metadata. | |
12 | func ClientConfig(m discovery.PluginMeta) *plugin.ClientConfig { | |
13 | return &plugin.ClientConfig{ | |
14 | Cmd: exec.Command(m.Path), | |
15 | HandshakeConfig: Handshake, | |
16 | Managed: true, | |
17 | Plugins: PluginMap, | |
18 | } | |
19 | } | |
20 | ||
21 | // Client returns a plugin client for the plugin described by the given metadata. | |
22 | func Client(m discovery.PluginMeta) *plugin.Client { | |
23 | return plugin.NewClient(ClientConfig(m)) | |
24 | } |