mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-04 04:28:08 +00:00 
			
		
		
		
	Prepare multiplexing support for database plugins (#16995)
* prepare multiplexing support for database plugins
This commit is contained in:
		@@ -4,30 +4,20 @@ import (
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
	"github.com/hashicorp/vault/api"
 | 
			
		||||
	"github.com/hashicorp/vault/plugins/database/redshift"
 | 
			
		||||
	"github.com/hashicorp/vault/sdk/database/dbplugin"
 | 
			
		||||
	"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	apiClientMeta := &api.PluginAPIClientMeta{}
 | 
			
		||||
	flags := apiClientMeta.FlagSet()
 | 
			
		||||
	flags.Parse(os.Args[1:])
 | 
			
		||||
 | 
			
		||||
	if err := Run(apiClientMeta.GetTLSConfig()); err != nil {
 | 
			
		||||
	if err := Run(); err != nil {
 | 
			
		||||
		log.Println(err)
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Run instantiates a RedShift object, and runs the RPC server for the plugin
 | 
			
		||||
func Run(apiTLSConfig *api.TLSConfig) error {
 | 
			
		||||
	dbType, err := redshift.New()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dbplugin.Serve(dbType.(dbplugin.Database), api.VaultPluginTLSProvider(apiTLSConfig))
 | 
			
		||||
func Run() error {
 | 
			
		||||
	dbplugin.ServeMultiplex(redshift.New)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user