// providerFactory produces a provider factory that runs up the executable
// file in the given cache package and uses go-plugin to implement
// providers.Interface against it.
providerFactory produces a provider factory that runs up the executable
file in the given cache package and uses go-plugin to implement
providers.Interface against it.
// providerFactory produces a provider factory that runs up the executable // file in the given cache package and uses go - plugin to implement // providers . Interface against it .
func providerFactory(meta *providercache.CachedProvider) providers.Factory {
	return func() (providers.Interface, error) {
		logger := hclog.New(&hclog.LoggerOptions{
			Name:   "plugin",
			Level:  hclog.Trace,
			Output: os.Stderr,
		})
		execFile, err := meta.ExecutableFile()
		if err != nil {
			return nil, err
		}
		config := &plugin.ClientConfig{
			HandshakeConfig:  tfplugin.Handshake,
			Logger:           logger,
			AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
			Managed:          true,
			Cmd:              exec.Command(execFile),
			AutoMTLS:         enableProviderAutoMTLS,
			VersionedPlugins: tfplugin.VersionedPlugins,
		}
		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)
		p.PluginClient = client
		return p, nil
	}
}
func providerFactory ( meta * providercache . CachedProvider ) providers . Factory { return func ( ) ( providers . Interface , error ) { logger := hclog . New ( & hclog . LoggerOptions { Name : " " , Level : hclog . Trace , Output : os . Stderr , } ) execFile , err := meta . ExecutableFile ( ) if err != nil { return nil , err } config := & plugin . ClientConfig { HandshakeConfig : tfplugin . Handshake , Logger : logger , AllowedProtocols : [ ] plugin . Protocol { plugin . ProtocolGRPC } , Managed : true , Cmd : exec . Command ( execFile ) , AutoMTLS : enableProviderAutoMTLS , VersionedPlugins : tfplugin . VersionedPlugins , } 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 ) p . PluginClient = client return p , nil } }
providerFactory produces a provider factory that runs up the executable
file in the given cache package and uses go-plugin to implement
providers.Interface against it.
providerFactory produces a provider factory that runs up the executable file in the given cache package and uses go - plugin to implement providers . Interface against it .
// store the client so that the plugin can kill the child process