Skip to content

Commit

Permalink
support .local configuration (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Dec 13, 2022
1 parent 4625f12 commit 94c00c5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"time"

"github.com/crowdsecurity/crowdsec/pkg/types"
log "github.com/sirupsen/logrus"

"gopkg.in/natefinch/lumberjack.v2"
"gopkg.in/yaml.v2"

"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/crowdsecurity/crowdsec/pkg/yamlpatch"
)

type PrometheusConfig struct {
Expand Down Expand Up @@ -47,12 +47,13 @@ func NewConfig(configPath string) (*bouncerConfig, error) {

config := &bouncerConfig{}

configBuff, err := ioutil.ReadFile(configPath)
patcher := yamlpatch.NewPatcher(configPath, ".local")
fcontent, err := patcher.MergedPatchContent()
if err != nil {
return &bouncerConfig{}, fmt.Errorf("failed to read %s : %v", configPath, err)
return &bouncerConfig{}, err
}

err = yaml.Unmarshal(configBuff, &config)
err = yaml.Unmarshal(fcontent, &config)
if err != nil {
return &bouncerConfig{}, fmt.Errorf("failed to unmarshal %s : %v", configPath, err)
}
Expand Down

0 comments on commit 94c00c5

Please sign in to comment.