open-vault/helper/builtinplugins/builtin.go

39 lines
869 B
Go
Raw Normal View History

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
)
type BuiltinFactory func() (interface{}, error)
2017-04-07 22:50:03 +00:00
var BuiltinPlugins *builtinPlugins = &builtinPlugins{
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 {
plugins map[string]BuiltinFactory
2017-04-07 22:50:03 +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
}
func (b *builtinPlugins) Keys() []string {
keys := make([]string, len(b.plugins))
i := 0
for k := range b.plugins {
keys[i] = k
i++
}
return keys
}