From c86e7231b223d532e26ab5449715c65b6b4e3fde Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 24 Sep 2018 17:21:24 +0200 Subject: bridge: validate config before use --- bridge/core/bridge.go | 5 +++++ bridge/core/interfaces.go | 3 +++ 2 files changed, 8 insertions(+) (limited to 'bridge/core') diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index d9d688ba..dd1f1337 100644 --- a/bridge/core/bridge.go +++ b/bridge/core/bridge.go @@ -200,6 +200,11 @@ func (b Bridge) loadConfig() (Configuration, error) { result[key] = value } + err = b.impl.ValidateConfig(result) + if err != nil { + return nil, errors.Wrap(err, "invalid configuration") + } + return result, nil } diff --git a/bridge/core/interfaces.go b/bridge/core/interfaces.go index 5ead3c8f..79b75606 100644 --- a/bridge/core/interfaces.go +++ b/bridge/core/interfaces.go @@ -15,6 +15,9 @@ type BridgeImpl interface { // for future use Configure(repo repository.RepoCommon) (Configuration, error) + // ValidateConfig check the configuration for error + ValidateConfig(conf Configuration) error + // Importer return an Importer implementation if the import is supported Importer() Importer -- cgit