2017-04-05 23:20:31 +00:00
|
|
|
package builtinplugins
|
|
|
|
|
2017-04-06 00:19:29 +00:00
|
|
|
import (
|
2017-04-13 20:48:32 +00:00
|
|
|
"github.com/hashicorp/vault/plugins/database/mysql"
|
|
|
|
"github.com/hashicorp/vault/plugins/database/postgresql"
|
2017-04-06 00:19:29 +00:00
|
|
|
)
|
2017-04-05 23:20:31 +00:00
|
|
|
|
2017-04-21 01:46:41 +00:00
|
|
|
type BuiltinFactory func() (interface{}, error)
|
|
|
|
|
2017-04-07 22:50:03 +00:00
|
|
|
var BuiltinPlugins *builtinPlugins = &builtinPlugins{
|
2017-04-21 01:46:41 +00:00
|
|
|
plugins: map[string]BuiltinFactory{
|
|
|
|
"mysql-database-plugin": mysql.New,
|
|
|
|
"postgresql-database-plugin": postgresql.New,
|
2017-04-07 22:50:03 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// The list of builtin plugins should not be changed by any other package, so we
|
|
|
|
// store them in an unexported variable in this unexported struct.
|
|
|
|
type builtinPlugins struct {
|
2017-04-21 01:46:41 +00:00
|
|
|
plugins map[string]BuiltinFactory
|
2017-04-07 22:50:03 +00:00
|
|
|
}
|
|
|
|
|
2017-04-21 01:46:41 +00:00
|
|
|
func (b *builtinPlugins) Get(name string) (BuiltinFactory, bool) {
|
2017-04-07 22:50:03 +00:00
|
|
|
f, ok := b.plugins[name]
|
|
|
|
return f, ok
|
2017-04-05 23:20:31 +00:00
|
|
|
}
|
2017-04-12 16:40:54 +00:00
|
|
|
|
|
|
|
func (b *builtinPlugins) Keys() []string {
|
|
|
|
keys := make([]string, len(b.plugins))
|
|
|
|
|
|
|
|
i := 0
|
|
|
|
for k := range b.plugins {
|
|
|
|
keys[i] = k
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
|
|
|
|
return keys
|
|
|
|
}
|