Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed Dec 18, 2023
1 parent 78da0be commit 9a4d963
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions collectors/dnsmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ func (c *DNSMessage) ReadConfigMatching(value interface{}) {
reflectedValue := reflect.ValueOf(value)
if reflectedValue.Kind() == reflect.Map {
keys := reflectedValue.MapKeys()
fileList := ""
srcKind := "string_list"
matchSrc := ""
srcKind := dnsutils.MatchKindString
for _, k := range keys {
v := reflectedValue.MapIndex(k)
if k.Interface().(string) == "match-source" {
fileList = v.Interface().(string)
matchSrc = v.Interface().(string)
}
if k.Interface().(string) == "source-kind" {
srcKind = v.Interface().(string)
}
}
if len(fileList) > 0 {
sourceData, err := c.LoadData(fileList, srcKind)
if len(matchSrc) > 0 {
sourceData, err := c.LoadData(matchSrc, srcKind)
if err != nil {
c.logger.Fatal(err)
}
Expand Down Expand Up @@ -162,12 +162,12 @@ func (c *DNSMessage) LoadFromURL(matchSource string, srcKind string) (MatchSourc
scanner := bufio.NewScanner(resp.Body)

switch srcKind {
case "regexp_list":
case dnsutils.MatchKindRegexp:
for scanner.Scan() {
matchSources.regexList = append(matchSources.regexList, regexp.MustCompile(scanner.Text()))
}
c.LogInfo("remote source loaded with %d entries kind=%s", len(matchSources.regexList), srcKind)
case "string_list":
case dnsutils.MatchKindString:
for scanner.Scan() {
matchSources.stringList = append(matchSources.stringList, scanner.Text())
}
Expand All @@ -190,12 +190,12 @@ func (c *DNSMessage) LoadFromFile(filePath string, srcKind string) (MatchSource,
scanner := bufio.NewScanner(file)

switch srcKind {
case "regexp_list":
case dnsutils.MatchKindRegexp:
for scanner.Scan() {
matchSources.regexList = append(matchSources.regexList, regexp.MustCompile(scanner.Text()))
}
c.LogInfo("file loaded with %d entries kind=%s", len(matchSources.regexList), srcKind)
case "string_list":
case dnsutils.MatchKindString:
for scanner.Scan() {
matchSources.stringList = append(matchSources.stringList, scanner.Text())
}
Expand Down
2 changes: 2 additions & 0 deletions dnsutils/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ const (

MatchingModeInclude = "include"
MatchingModeGreaterThan = "greater-than"
MatchKindString = "string_list"
MatchKindRegexp = "regexp_list"
)

0 comments on commit 9a4d963

Please sign in to comment.