Skip to content

Commit

Permalink
Remove default value for "ffdx"
Browse files Browse the repository at this point in the history
Handle it as a specific one-off instead of setting a Viper default.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Jun 27, 2022
1 parent c17d253 commit 89f9025
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ nav_order: 2

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

## dataexchange.ffdx

Expand Down
2 changes: 1 addition & 1 deletion internal/dataexchange/dxfactory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func InitConfig(config config.ArraySection) {
}

func InitConfigDeprecated(config config.Section) {
config.AddKnownKey(coreconfig.PluginConfigType, NewFFDXPluginName)
config.AddKnownKey(coreconfig.PluginConfigType)
for name, plugin := range pluginsByName {
plugin().InitConfig(config.SubSection(name))
}
Expand Down
5 changes: 5 additions & 0 deletions internal/namespace/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/hyperledger/firefly/pkg/identity"
"github.com/hyperledger/firefly/pkg/sharedstorage"
"github.com/hyperledger/firefly/pkg/tokens"
"github.com/spf13/viper"
)

var (
Expand Down Expand Up @@ -436,6 +437,10 @@ func (nm *namespaceManager) getDataExchangePlugins(ctx context.Context) (plugins
// check deprecated config
if len(plugins) == 0 {
pluginType := deprecatedDataexchangeConfig.GetString(coreconfig.PluginConfigType)
if pluginType == "" && viper.Get("dataexchange") != nil {
// very old config allowed omitting an explicit "type" for data exchange
pluginType = dxfactory.NewFFDXPluginName
}
if pluginType != "" {
plugin, err := dxfactory.GetPlugin(ctx, pluginType)
if err != nil {
Expand Down
17 changes: 17 additions & 0 deletions internal/namespace/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,23 @@ func TestDeprecatedDataExchangePluginBadType(t *testing.T) {
assert.Regexp(t, "FF10213.*wrong", err)
}

func TestDeprecatedDataExchangePluginDefaultType(t *testing.T) {
nm := newTestNamespaceManager(true)
defer nm.cleanup(t)
dxfactory.InitConfigDeprecated(deprecatedDataexchangeConfig)

viper.SetConfigType("yaml")
err := viper.ReadConfig(strings.NewReader(`
dataexchange:
ffdx:
url: http://dx
`))
assert.NoError(t, err)

_, err = nm.getDataExchangePlugins(context.Background())
assert.NoError(t, err)
}

func TestDataExchangePlugin(t *testing.T) {
nm := newTestNamespaceManager(true)
defer nm.cleanup(t)
Expand Down

0 comments on commit 89f9025

Please sign in to comment.