// unmanagedProviderFactory produces a provider factory that uses the passed
// reattach information to connect to go-plugin processes that are already
// running, and implements providers.Interface against it.
unmanagedProviderFactory produces a provider factory that uses the passed
reattach information to connect to go-plugin processes that are already
running, and implements providers.Interface against it.
// unmanagedProviderFactory produces a provider factory that uses the passed // reattach information to connect to go - plugin processes that are already // running and implements providers . Interface against it .
func unmanagedProviderFactory(provider addrs.Provider, reattach *plugin.ReattachConfig) providers.Factory {
	return func() (providers.Interface, error) {
		logger := hclog.New(&hclog.LoggerOptions{
			Name:   "unmanaged-plugin",
			Level:  hclog.Trace,
			Output: os.Stderr,
		})
		config := &plugin.ClientConfig{
			HandshakeConfig:  tfplugin.Handshake,
			Logger:           logger,
			AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
			Managed:          false,
			Reattach:         reattach,
		}
		if plugins, ok := tfplugin.VersionedPlugins[5]; !ok {
			return nil, fmt.Errorf("no supported plugins for protocol 5")
		} else {
			config.Plugins = plugins
		}
		client := plugin.NewClient(config)
		rpcClient, err := client.Client()
		if err != nil {
			return nil, err
		}
		raw, err := rpcClient.Dispense(tfplugin.ProviderPluginName)
		if err != nil {
			return nil, err
		}
		p := raw.(*tfplugin.GRPCProvider)
		return p, nil
	}
}
func unmanagedProviderFactory ( provider addrs . Provider , reattach * plugin . ReattachConfig ) providers . Factory { return func ( ) ( providers . Interface , error ) { logger := hclog . New ( & hclog . LoggerOptions { Name : " " , Level : hclog . Trace , Output : os . Stderr , } ) config := & plugin . ClientConfig { HandshakeConfig : tfplugin . Handshake , Logger : logger , AllowedProtocols : [ ] plugin . Protocol { plugin . ProtocolGRPC } , Managed : false , Reattach : reattach , } if plugins , ok := tfplugin . VersionedPlugins [ 5 ] ; ! ok { return nil , fmt . Errorf ( " " ) } else { config . Plugins = plugins } client := plugin . NewClient ( config ) rpcClient , err := client . Client ( ) if err != nil { return nil , err } raw , err := rpcClient . Dispense ( tfplugin . ProviderPluginName ) if err != nil { return nil , err } p := raw . ( * tfplugin . GRPCProvider ) return p , nil } }
unmanagedProviderFactory produces a provider factory that uses the passed
reattach information to connect to go-plugin processes that are already
running, and implements providers.Interface against it.
unmanagedProviderFactory produces a provider factory that uses the passed reattach information to connect to go - plugin processes that are already running and implements providers . Interface against it .
// TODO: we probably shouldn't hardcode the protocol version // here, but it'll do for now, because only one protocol // version is supported. Eventually, we'll probably want to // sneak it into the JSON ReattachConfigs.