Add checksum attribute

This commit is contained in:
Brian Kassouf 2017-03-10 14:10:42 -08:00
parent a11911d4d4
commit 71b81aad23
3 changed files with 14 additions and 2 deletions

View file

@ -84,7 +84,11 @@ func PluginFactory(conf *DatabaseConfig) (DatabaseType, error) {
return nil, errors.New("ERROR")
}
db, err := newPluginClient(conf.PluginCommand)
if conf.PluginChecksum == "" {
return nil, errors.New("ERROR")
}
db, err := newPluginClient(conf.PluginCommand, conf.PluginChecksum)
if err != nil {
return nil, err
}
@ -109,6 +113,7 @@ type DatabaseConfig struct {
MaxIdleConnections int `json:"max_idle_connections" structs:"max_idle_connections" mapstructure:"max_idle_connections"`
MaxConnectionLifetime time.Duration `json:"max_connection_lifetime" structs:"max_connection_lifetime" mapstructure:"max_connection_lifetime"`
PluginCommand string `json:"plugin_command" structs:"plugin_command" mapstructure:"plugin_command"`
PluginChecksum string `json:"plugin_checksum" structs:"plugin_checksum" mapstructure:"plugin_checksum"`
}
func (dc *DatabaseConfig) GetFactory() Factory {

View file

@ -44,7 +44,7 @@ func (dc *DatabasePluginClient) Close() {
dc.client.Kill()
}
func newPluginClient(command string) (DatabaseType, error) {
func newPluginClient(command, checksum string) (DatabaseType, error) {
// pluginMap is the map of plugins we can dispense.
var pluginMap = map[string]plugin.Plugin{
"database": new(DatabasePlugin),

View file

@ -128,6 +128,12 @@ reduced to the same size.`,
Description: `Maximum amount of time a connection may be reused;
a zero or negative value reuses connections forever.`,
},
"plugin_checksum": &framework.FieldSchema{
Type: framework.TypeString,
Description: `Maximum amount of time a connection may be reused;
a zero or negative value reuses connections forever.`,
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
@ -197,6 +203,7 @@ func (b *databaseBackend) connectionWriteHandler(factory dbs.Factory) framework.
MaxIdleConnections: maxIdleConns,
MaxConnectionLifetime: maxConnLifetime,
PluginCommand: data.Get("plugin_command").(string),
PluginChecksum: data.Get("plugin_checksum").(string),
}
name := data.Get("name").(string)