2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-08-11 01:28:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/plugins/database/mysql"
|
2020-10-22 21:43:19 +00:00
|
|
|
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
2017-08-11 01:28:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-10-22 21:43:19 +00:00
|
|
|
err := Run()
|
2017-08-11 01:28:18 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
2020-10-22 21:43:19 +00:00
|
|
|
|
|
|
|
// Run instantiates a MySQL object, and runs the RPC server for the plugin
|
|
|
|
func Run() error {
|
|
|
|
var f func() (interface{}, error)
|
2021-02-11 21:08:32 +00:00
|
|
|
f = mysql.New(mysql.DefaultLegacyUserNameTemplate)
|
2020-10-22 21:43:19 +00:00
|
|
|
dbType, err := f()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
dbplugin.Serve(dbType.(dbplugin.Database))
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|