From e9a92ecb4e354383bf14b09f9a704124ad80902f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Coavoux?= Date: Mon, 1 Mar 2021 20:37:23 -0500 Subject: [PATCH] Fix linting for golang 1.15.8 --- collector/collector.go | 2 +- config/config.go | 18 +++++++++--------- generator/config.go | 2 +- generator/tree.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index d7be2e4dc..a1dbfffe3 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -189,7 +189,7 @@ func ScrapeTarget(ctx context.Context, target string, config *config.Module, log // evaluate rules newGet := config.Get newWalk := config.Walk - for _, filter := range config.Filters{ + for _, filter := range config.Filters { var pdus []gosnmp.SnmpPDU allowedList := []string{} diff --git a/config/config.go b/config/config.go index c01d667f6..8a2580e63 100644 --- a/config/config.go +++ b/config/config.go @@ -71,11 +71,11 @@ type WalkParams struct { type Module struct { // A list of OIDs. - Walk []string `yaml:"walk,omitempty"` - Get []string `yaml:"get,omitempty"` - Metrics []*Metric `yaml:"metrics"` - WalkParams WalkParams `yaml:",inline"` - Filters []DynamicFilter `yaml:"filters,omitempty"` + Walk []string `yaml:"walk,omitempty"` + Get []string `yaml:"get,omitempty"` + Metrics []*Metric `yaml:"metrics"` + WalkParams WalkParams `yaml:",inline"` + Filters []DynamicFilter `yaml:"filters,omitempty"` } func (c *Module) UnmarshalYAML(unmarshal func(interface{}) error) error { @@ -183,18 +183,18 @@ func (c WalkParams) ConfigureSNMP(g *gosnmp.GoSNMP) { } type Filters struct { - Static []StaticFilter `yaml:"static,omitempty"` + Static []StaticFilter `yaml:"static,omitempty"` Dynamic []DynamicFilter `yaml:"dynamic,omitempty"` } type StaticFilter struct { - Targets []string `yaml:"targets,omitempty"` + Targets []string `yaml:"targets,omitempty"` Instances []string `yaml:"instances,omitempty"` } type DynamicFilter struct { - Oid string `yaml:"oid"` + Oid string `yaml:"oid"` Targets []string `yaml:"targets,omitempty"` - Values []string `yaml:"values,omitempty"` + Values []string `yaml:"values,omitempty"` } type Metric struct { diff --git a/generator/config.go b/generator/config.go index 1661b416d..1833126da 100644 --- a/generator/config.go +++ b/generator/config.go @@ -50,7 +50,7 @@ type ModuleConfig struct { Lookups []*Lookup `yaml:"lookups"` WalkParams config.WalkParams `yaml:",inline"` Overrides map[string]MetricOverrides `yaml:"overrides"` - Filters config.Filters `yaml:"filters,omitempty"` + Filters config.Filters `yaml:"filters,omitempty"` } type Lookup struct { diff --git a/generator/tree.go b/generator/tree.go index 258b8b0a5..4f645b94e 100644 --- a/generator/tree.go +++ b/generator/tree.go @@ -379,7 +379,7 @@ func generateConfigModule(cfg *ModuleConfig, node *Node, nameToNode map[string]* // Build an map of all oid targeted by a filter to access it easily later filterMap := map[string][]string{} - for _, filter := range cfg.Filters.Static{ + for _, filter := range cfg.Filters.Static { for _, oid := range filter.Targets { n, ok := nameToNode[oid] if ok {