Prepare multiplexing support for database plugins (#16995)
* prepare multiplexing support for database plugins
This commit is contained in:
parent
98fffbe949
commit
10121fed37
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
plugins/multiplexing: Added multiplexing support to database plugins if run as external plugins
|
||||
```
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/cassandra"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a Cassandra object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := cassandra.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(cassandra.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/hana"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a HANA object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := hana.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(hana.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/influxdb"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a Influxdb object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := influxdb.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(influxdb.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/mongodb"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a MongoDB object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := mongodb.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(mongodb.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/mssql"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a MSSQL object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := mssql.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(mssql.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/mysql"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -20,12 +20,8 @@ func main() {
|
|||
func Run() error {
|
||||
var f func() (interface{}, error)
|
||||
f = mysql.New(mysql.DefaultUserNameTemplate)
|
||||
dbType, err := f()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(f)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/vault/plugins/database/postgresql"
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,12 +18,7 @@ func main() {
|
|||
|
||||
// Run instantiates a PostgreSQL object, and runs the RPC server for the plugin
|
||||
func Run() error {
|
||||
dbType, err := postgresql.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbplugin.Serve(dbType.(dbplugin.Database))
|
||||
dbplugin.ServeMultiplex(postgresql.New)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue