Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Enable separate external/internal location
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Dec 2, 2022
1 parent a65aee2 commit f5c649c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewConfig(app string) (*Config, error) {
}
case "sync":
requiredConfVars = []string{
"broker.host", "broker.port", "broker.user", "broker.password", "broker.routingkey", "db.host", "db.port", "db.user", "db.password", "db.database", "sync.host", "sync.password", "sync.user",
"broker.host", "broker.port", "broker.user", "broker.password", "broker.routingkey",
}
default:
requiredConfVars = []string{
Expand Down Expand Up @@ -234,17 +234,21 @@ func NewConfig(app string) (*Config, error) {

return c, nil
case "sync":
err = c.configDatabase()
if err != nil {
return nil, err
if viper.IsSet("db.host") {
err = c.configDatabase()
if err != nil {
return nil, err
}
}

err = c.configAPI()
if err != nil {
return nil, err
}

c.configSync()
if viper.IsSet("sync.host") {
c.configSync()
}

return c, nil
}
Expand Down
1 change: 1 addition & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ func (suite *TestSuite) TestNotifyConfiguration() {

func (suite *TestSuite) TestSyncConfiguration() {
// At this point we should fail because we lack configuration
viper.Reset()
config, err := NewConfig("sync")
assert.Error(suite.T(), err)
assert.Nil(suite.T(), config)
Expand Down

0 comments on commit f5c649c

Please sign in to comment.