Skip to content

Commit

Permalink
type configGetter
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Jan 31, 2024
1 parent c7c0b1a commit b3d71e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions cmd/crowdsec-cli/bouncers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
middlewares "github.com/crowdsecurity/crowdsec/pkg/apiserver/middlewares/v1"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
Expand All @@ -38,10 +37,10 @@ func askYesNo(message string, defaultAnswer bool) (bool, error) {

type cliBouncers struct {
db *database.Client
cfg func() *csconfig.Config
cfg configGetter
}

func NewCLIBouncers(getconfig func() *csconfig.Config) *cliBouncers {
func NewCLIBouncers(getconfig configGetter) *cliBouncers {
return &cliBouncers{
cfg: getconfig,
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/crowdsec-cli/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func getLastHeartbeat(m *ent.Machine) (string, bool) {

type cliMachines struct{
db *database.Client
cfg func() *csconfig.Config
cfg configGetter
}

func NewCLIMachines(getconfig func() *csconfig.Config) *cliMachines {
func NewCLIMachines(getconfig configGetter) *cliMachines {
return &cliMachines{
cfg: getconfig,
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/crowdsec-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var mergedConfig string
// flagBranch overrides the value in csConfig.Cscli.HubBranch
var flagBranch = ""

type configGetter func() *csconfig.Config

func initConfig() {
var err error

Expand Down

0 comments on commit b3d71e9

Please sign in to comment.