Skip to content

Commit 1322d87

Browse files
committed
Allow plugin config to be omitted
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
1 parent 04aec20 commit 1322d87

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

internal/namespace/manager.go

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,17 @@ func (nm *namespaceManager) getDatabasePlugins(ctx context.Context) (plugins map
375375
// check for deprecated config
376376
if len(plugins) == 0 {
377377
pluginType := deprecatedDatabaseConfig.GetString(coreconfig.PluginConfigType)
378-
plugin, err := difactory.GetPlugin(ctx, deprecatedDatabaseConfig.GetString(coreconfig.PluginConfigType))
379-
if err != nil {
380-
return nil, err
381-
}
382-
log.L(ctx).Warnf("Your database config uses a deprecated configuration structure - the database configuration has been moved under the 'plugins' section")
383-
name := "database_0"
384-
plugins[name] = databasePlugin{
385-
config: deprecatedDatabaseConfig.SubSection(pluginType),
386-
plugin: plugin,
378+
if pluginType != "" {
379+
plugin, err := difactory.GetPlugin(ctx, deprecatedDatabaseConfig.GetString(coreconfig.PluginConfigType))
380+
if err != nil {
381+
return nil, err
382+
}
383+
log.L(ctx).Warnf("Your database config uses a deprecated configuration structure - the database configuration has been moved under the 'plugins' section")
384+
name := "database_0"
385+
plugins[name] = databasePlugin{
386+
config: deprecatedDatabaseConfig.SubSection(pluginType),
387+
plugin: plugin,
388+
}
387389
}
388390
}
389391

@@ -431,17 +433,20 @@ func (nm *namespaceManager) getDataExchangePlugins(ctx context.Context) (plugins
431433
}
432434
}
433435

436+
// check deprecated config
434437
if len(plugins) == 0 {
435438
pluginType := deprecatedDataexchangeConfig.GetString(coreconfig.PluginConfigType)
436-
plugin, err := dxfactory.GetPlugin(ctx, pluginType)
437-
if err != nil {
438-
return nil, err
439-
}
440-
log.L(ctx).Warnf("Your data exchange config uses a deprecated configuration structure - the data exchange configuration has been moved under the 'plugins' section")
441-
name := "dataexchange_0"
442-
plugins[name] = dataExchangePlugin{
443-
config: deprecatedDataexchangeConfig.SubSection(pluginType),
444-
plugin: plugin,
439+
if pluginType != "" {
440+
plugin, err := dxfactory.GetPlugin(ctx, pluginType)
441+
if err != nil {
442+
return nil, err
443+
}
444+
log.L(ctx).Warnf("Your data exchange config uses a deprecated configuration structure - the data exchange configuration has been moved under the 'plugins' section")
445+
name := "dataexchange_0"
446+
plugins[name] = dataExchangePlugin{
447+
config: deprecatedDataexchangeConfig.SubSection(pluginType),
448+
plugin: plugin,
449+
}
445450
}
446451
}
447452

@@ -496,15 +501,17 @@ func (nm *namespaceManager) getBlockchainPlugins(ctx context.Context) (plugins m
496501
// check deprecated config
497502
if len(plugins) == 0 {
498503
pluginType := deprecatedBlockchainConfig.GetString(coreconfig.PluginConfigType)
499-
plugin, err := bifactory.GetPlugin(ctx, pluginType)
500-
if err != nil {
501-
return nil, err
502-
}
503-
log.L(ctx).Warnf("Your blockchain config uses a deprecated configuration structure - the blockchain configuration has been moved under the 'plugins' section")
504-
name := "blockchain_0"
505-
plugins[name] = blockchainPlugin{
506-
config: deprecatedBlockchainConfig.SubSection(pluginType),
507-
plugin: plugin,
504+
if pluginType != "" {
505+
plugin, err := bifactory.GetPlugin(ctx, pluginType)
506+
if err != nil {
507+
return nil, err
508+
}
509+
log.L(ctx).Warnf("Your blockchain config uses a deprecated configuration structure - the blockchain configuration has been moved under the 'plugins' section")
510+
name := "blockchain_0"
511+
plugins[name] = blockchainPlugin{
512+
config: deprecatedBlockchainConfig.SubSection(pluginType),
513+
plugin: plugin,
514+
}
508515
}
509516
}
510517

@@ -535,15 +542,17 @@ func (nm *namespaceManager) getSharedStoragePlugins(ctx context.Context) (plugin
535542
// check deprecated config
536543
if len(plugins) == 0 {
537544
pluginType := deprecatedSharedStorageConfig.GetString(coreconfig.PluginConfigType)
538-
plugin, err := ssfactory.GetPlugin(ctx, pluginType)
539-
if err != nil {
540-
return nil, err
541-
}
542-
log.L(ctx).Warnf("Your shared storage config uses a deprecated configuration structure - the shared storage configuration has been moved under the 'plugins' section")
543-
name := "sharedstorage_0"
544-
plugins[name] = sharedStoragePlugin{
545-
config: deprecatedSharedStorageConfig.SubSection(pluginType),
546-
plugin: plugin,
545+
if pluginType != "" {
546+
plugin, err := ssfactory.GetPlugin(ctx, pluginType)
547+
if err != nil {
548+
return nil, err
549+
}
550+
log.L(ctx).Warnf("Your shared storage config uses a deprecated configuration structure - the shared storage configuration has been moved under the 'plugins' section")
551+
name := "sharedstorage_0"
552+
plugins[name] = sharedStoragePlugin{
553+
config: deprecatedSharedStorageConfig.SubSection(pluginType),
554+
plugin: plugin,
555+
}
547556
}
548557
}
549558

0 commit comments

Comments
 (0)