From 71b81aad23d62ae0a49f15995f39226403bb4d8b Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Fri, 10 Mar 2017 14:10:42 -0800 Subject: [PATCH] Add checksum attribute --- builtin/logical/database/dbs/db.go | 7 ++++++- builtin/logical/database/dbs/plugin.go | 2 +- builtin/logical/database/path_config_connection.go | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/builtin/logical/database/dbs/db.go b/builtin/logical/database/dbs/db.go index bf78d29e6..33cf7361a 100644 --- a/builtin/logical/database/dbs/db.go +++ b/builtin/logical/database/dbs/db.go @@ -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 { diff --git a/builtin/logical/database/dbs/plugin.go b/builtin/logical/database/dbs/plugin.go index e495dbf14..bbd8d4ce4 100644 --- a/builtin/logical/database/dbs/plugin.go +++ b/builtin/logical/database/dbs/plugin.go @@ -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), diff --git a/builtin/logical/database/path_config_connection.go b/builtin/logical/database/path_config_connection.go index 4780dc492..31f618281 100644 --- a/builtin/logical/database/path_config_connection.go +++ b/builtin/logical/database/path_config_connection.go @@ -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)