light pkg/parser cleanup (#2279)

* pkg/parser: clean up imports
* remove duplicate import
* simplify boolean expression
* don't check length before range
* if..else if.. -> switch/case
* errors.Wrap -> fmt.Errorf
* typo, lint
* redundant break
This commit is contained in:
mmetc 2023-06-13 13:16:13 +02:00 committed by GitHub
parent 76429f033a
commit b9a3acb03f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 108 additions and 115 deletions

View file

@ -7,12 +7,13 @@ import (
"sort"
"strings"
log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/grokky"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
"github.com/crowdsecurity/crowdsec/pkg/fflag"
"github.com/crowdsecurity/grokky"
log "github.com/sirupsen/logrus"
)
type UnixParserCtx struct {
@ -117,7 +118,7 @@ func LoadParsers(cConfig *csconfig.Config, parsers *Parsers) (*Parsers, error) {
parsers.EnricherCtx, err = Loadplugin(cConfig.Crowdsec.DataDir)
if err != nil {
return parsers, fmt.Errorf("Failed to load enrich plugin : %v", err)
return parsers, fmt.Errorf("failed to load enrich plugin : %v", err)
}
/*
@ -135,8 +136,8 @@ func LoadParsers(cConfig *csconfig.Config, parsers *Parsers) (*Parsers, error) {
log.Infof("Loading postoverflow parsers")
parsers.Povfwnodes, err = LoadStages(parsers.PovfwStageFiles, parsers.Povfwctx, parsers.EnricherCtx)
} else {
parsers.Povfwnodes = []Node{}
log.Infof("No postoverflow parsers to load")
parsers.Povfwnodes = []Node{}
}
if err != nil {