Skip to content

Commit

Permalink
support crowdsec-firewall-bouncer.yaml.local (crowdsecurity#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Oct 17, 2022
1 parent 9d08158 commit 3da0ded
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ linters:
- structcheck # The owner seems to have abandoned the linter. Replaced by unused.
- varcheck # The owner seems to have abandoned the linter. Replaced by unused.

#
# Disabled
#
- gci # Gci control golang package import order and make it always deterministic.

#
# Enabled
#
Expand All @@ -66,7 +71,6 @@ linters:
# - exportloopref # checks for pointers to enclosing loop variables
# - forcetypeassert # finds forced type assertions
# - funlen # Tool for detection of long functions
# - gci # Gci control golang package import order and make it always deterministic.
# - gochecknoinits # Checks that no init functions are present in Go code
# - godot # Check if comments end in a period
# - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
Expand Down
3 changes: 2 additions & 1 deletion backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"runtime"

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

"github.com/crowdsecurity/crowdsec/pkg/models"
)

type backend interface {
Expand Down
13 changes: 7 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package main

import (
"fmt"
"os"

"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/pkg/errors"
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 @@ -68,12 +69,12 @@ type bouncerConfig struct {
func newConfig(configPath string) (*bouncerConfig, error) {
config := &bouncerConfig{}

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

err = yaml.Unmarshal(configBuff, &config)
err = yaml.Unmarshal(fcontent, &config)
if err != nil {
return &bouncerConfig{}, errors.Wrapf(err, "failed to unmarshal %s", configPath)
}
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import (
"syscall"

"github.com/coreos/go-systemd/daemon"
"github.com/crowdsecurity/cs-firewall-bouncer/pkg/version"
csbouncer "github.com/crowdsecurity/go-cs-bouncer"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/writer"
"gopkg.in/tomb.v2"

csbouncer "github.com/crowdsecurity/go-cs-bouncer"

"github.com/crowdsecurity/cs-firewall-bouncer/pkg/version"
)

const (
Expand Down

0 comments on commit 3da0ded

Please sign in to comment.