Skip to content

Commit

Permalink
Change empty config check
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelreiswildlife committed Sep 26, 2023
1 parent c6882f3 commit 04720e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,15 @@ func (app *App) loadConfiguration() error {

func (app *App) configureEnrichment() {
// If a specific Redis instance is not provided, use the same one as the rest of the service.
if app.ParsedConfig.Enrichment.Cache == nil {
if app.ParsedConfig.Enrichment.Cache.Addr == "" {
host := app.Config.GetString("redis.host")
port := app.Config.GetInt("redis.port")
password := app.Config.GetString("redis.password")

app.ParsedConfig.Enrichment.Cache = &config.Cache{Addr: fmt.Sprintf("%s:%d", host, port)}
app.ParsedConfig.Enrichment.Cache = config.Cache{
Addr: fmt.Sprintf("%s:%d", host, port),
Password: password,
}
}

redisClient := redis.NewClient(&redis.Options{
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type (
// WebhookTimeout is the timeout for the webhook call.
WebhookTimeout time.Duration `mapstructure:"webhook_timeout"`

Cache *Cache `mapstructure:"cache"`
Cache Cache `mapstructure:"cache"`
}

Cache struct {
Expand Down
2 changes: 1 addition & 1 deletion config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enrichment:
cache:
disabled: false
ttl: 24h
addrs: "localhost:6739"
addrs: ""
username: ""
webhook_timeout: 500ms
cloud_save:
Expand Down

0 comments on commit 04720e4

Please sign in to comment.