Skip to content

Commit 89f9025

Browse files
committed
Remove default value for "ffdx"
Handle it as a specific one-off instead of setting a Viper default. Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
1 parent c17d253 commit 89f9025

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

docs/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ nav_order: 2
336336

337337
|Key|Description|Type|Default Value|
338338
|---|-----------|----|-------------|
339-
|type|The Data Exchange plugin to use|`string`|`ffdx`
339+
|type|The Data Exchange plugin to use|`string`|`<nil>`
340340

341341
## dataexchange.ffdx
342342

internal/dataexchange/dxfactory/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func InitConfig(config config.ArraySection) {
4444
}
4545

4646
func InitConfigDeprecated(config config.Section) {
47-
config.AddKnownKey(coreconfig.PluginConfigType, NewFFDXPluginName)
47+
config.AddKnownKey(coreconfig.PluginConfigType)
4848
for name, plugin := range pluginsByName {
4949
plugin().InitConfig(config.SubSection(name))
5050
}

internal/namespace/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
"github.com/hyperledger/firefly/pkg/identity"
4848
"github.com/hyperledger/firefly/pkg/sharedstorage"
4949
"github.com/hyperledger/firefly/pkg/tokens"
50+
"github.com/spf13/viper"
5051
)
5152

5253
var (
@@ -436,6 +437,10 @@ func (nm *namespaceManager) getDataExchangePlugins(ctx context.Context) (plugins
436437
// check deprecated config
437438
if len(plugins) == 0 {
438439
pluginType := deprecatedDataexchangeConfig.GetString(coreconfig.PluginConfigType)
440+
if pluginType == "" && viper.Get("dataexchange") != nil {
441+
// very old config allowed omitting an explicit "type" for data exchange
442+
pluginType = dxfactory.NewFFDXPluginName
443+
}
439444
if pluginType != "" {
440445
plugin, err := dxfactory.GetPlugin(ctx, pluginType)
441446
if err != nil {

internal/namespace/manager_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,23 @@ func TestDeprecatedDataExchangePluginBadType(t *testing.T) {
563563
assert.Regexp(t, "FF10213.*wrong", err)
564564
}
565565

566+
func TestDeprecatedDataExchangePluginDefaultType(t *testing.T) {
567+
nm := newTestNamespaceManager(true)
568+
defer nm.cleanup(t)
569+
dxfactory.InitConfigDeprecated(deprecatedDataexchangeConfig)
570+
571+
viper.SetConfigType("yaml")
572+
err := viper.ReadConfig(strings.NewReader(`
573+
dataexchange:
574+
ffdx:
575+
url: http://dx
576+
`))
577+
assert.NoError(t, err)
578+
579+
_, err = nm.getDataExchangePlugins(context.Background())
580+
assert.NoError(t, err)
581+
}
582+
566583
func TestDataExchangePlugin(t *testing.T) {
567584
nm := newTestNamespaceManager(true)
568585
defer nm.cleanup(t)

0 commit comments

Comments
 (0)