address golangci-lint
This commit is contained in:
parent
1756fe7ccc
commit
27187efdf8
|
|
@ -7,4 +7,4 @@ before_install:
|
|||
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
|
||||
script:
|
||||
- go test ./...
|
||||
- golangci-lint run --enable-all
|
||||
- golangci-lint run --disable errcheck
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ type Config struct {
|
|||
// Datadog allows the data to be context aware with configuration
|
||||
type Datadog struct {
|
||||
*Config `json:"datadog" toml:"datadog" xml:"datadog" yaml:"datadog"`
|
||||
options []statsd.Option
|
||||
options []statsd.Option // nolint
|
||||
}
|
||||
|
||||
// DatadogUnifi is returned by New() after you provide a Config.
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
package datadogunifi
|
||||
|
||||
import (
|
||||
"github.com/unpoller/unifi"
|
||||
)
|
||||
|
||||
// reportIDS generates intrusion detection datapoints for Datadog.
|
||||
// These points can be passed directly to datadog.
|
||||
func (u *DatadogUnifi) reportIDS(r report, i *unifi.IDS) {
|
||||
tags := []string{
|
||||
tag("site_name", i.SiteName),
|
||||
tag("source", i.SourceName),
|
||||
tag("in_iface", i.InIface),
|
||||
tag("event_type", i.EventType),
|
||||
tag("proto", i.Proto),
|
||||
tag("app_proto", i.AppProto),
|
||||
tag("usg_ip", i.USGIP),
|
||||
tag("country_code", i.SourceIPGeo.CountryCode),
|
||||
tag("country_name", i.SourceIPGeo.CountryName),
|
||||
tag("city", i.SourceIPGeo.City),
|
||||
tag("src_ip_ASN", i.SrcIPASN),
|
||||
tag("usg_ip_ASN", i.USGIPASN),
|
||||
tag("alert_category", i.InnerAlertCategory),
|
||||
tag("subsystem", i.Subsystem),
|
||||
tag("catname", i.Catname),
|
||||
}
|
||||
|
||||
metricName := metricNamespace("intrusion_detect")
|
||||
r.reportCount(metricName("count"), 1, tags)
|
||||
}
|
||||
|
|
@ -3,8 +3,6 @@ package datadogunifi
|
|||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/unpoller/unifi"
|
||||
)
|
||||
|
||||
func tag(name string, value interface{}) string {
|
||||
|
|
@ -49,31 +47,3 @@ func cleanTags(tags map[string]string) map[string]string {
|
|||
|
||||
return tags
|
||||
}
|
||||
|
||||
// cleanFields removes any field with a default (or empty) value.
|
||||
func cleanFields(fields map[string]interface{}) map[string]interface{} { //nolint:cyclop
|
||||
for s := range fields {
|
||||
switch v := fields[s].(type) {
|
||||
case nil:
|
||||
delete(fields, s)
|
||||
case int, int64, float64:
|
||||
if v == 0 {
|
||||
delete(fields, s)
|
||||
}
|
||||
case unifi.FlexBool:
|
||||
if v.Txt == "" {
|
||||
delete(fields, s)
|
||||
}
|
||||
case unifi.FlexInt:
|
||||
if v.Txt == "" {
|
||||
delete(fields, s)
|
||||
}
|
||||
case string:
|
||||
if v == "" {
|
||||
delete(fields, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue