Update the api for serving plugins and provide a utility to pass TLS data for commuinicating with the vault process

This commit is contained in:
Brian Kassouf
2017-05-02 14:40:11 -07:00
parent 7f92c5f47f
commit 1df8ec9ef7
15 changed files with 310 additions and 153 deletions

View File

@@ -4,11 +4,16 @@ import (
"fmt"
"os"
"github.com/hashicorp/vault/helper/pluginutil"
"github.com/hashicorp/vault/plugins/database/postgresql"
)
func main() {
err := postgresql.Run()
apiClientMeta := &pluginutil.APIClientMeta{}
flags := apiClientMeta.FlagSet()
flags.Parse(os.Args)
err := postgresql.Run(apiClientMeta.GetTLSConfig())
if err != nil {
fmt.Println(err)
os.Exit(1)

View File

@@ -6,8 +6,10 @@ import (
"strings"
"time"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
"github.com/hashicorp/vault/helper/strutil"
"github.com/hashicorp/vault/plugins"
"github.com/hashicorp/vault/plugins/helper/database/connutil"
"github.com/hashicorp/vault/plugins/helper/database/credsutil"
"github.com/hashicorp/vault/plugins/helper/database/dbutil"
@@ -35,13 +37,13 @@ func New() (interface{}, error) {
}
// Run instantiates a PostgreSQL object, and runs the RPC server for the plugin
func Run() error {
func Run(apiTLSConfig *api.TLSConfig) error {
dbType, err := New()
if err != nil {
return err
}
dbplugin.Serve(dbType.(*PostgreSQL))
plugins.Serve(dbType.(*PostgreSQL), apiTLSConfig)
return nil
}