From 70216e560a925e41af8c915ad200224e737f5e31 Mon Sep 17 00:00:00 2001 From: Antonio Escalera Date: Wed, 13 Jul 2022 18:48:04 -0400 Subject: [PATCH] refactor(internal/circonus): Metric filters parsing defaults to v1.20+, checks errors Refactor metric filters parsing to be simpler and check all errors issue #CIRC-8497 This change refactors code to be simpler (more easily readable) and check all errors * Tags: errors metric filters v1.20+ parse --- internal/circonus/metric_filters.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/circonus/metric_filters.go b/internal/circonus/metric_filters.go index fc6e473c..af75c1c0 100644 --- a/internal/circonus/metric_filters.go +++ b/internal/circonus/metric_filters.go @@ -140,19 +140,15 @@ func (c *Check) defaultFilters() [][]string { var defaultMetricFiltersData []byte - currversion, err := version.NewVersion(c.clusterVers) + v120, err := version.NewVersion(v120str) if err != nil { - c.log.Warn().Err(err).Msg("parsing api version") - currversion, _ = version.NewVersion(v120str) + c.log.Warn().Err(err).Msg("parsing " + v120str) } - v120, err := version.NewVersion(v120str) + currversion, err := version.NewVersion(c.clusterVers) if err != nil { - c.log.Warn().Err(err).Msg("parsing" + v120str) - return [][]string{ - {"deny", "^$", "empty"}, - {"allow", "^.+$", "all"}, - } + c.log.Warn().Err(err).Msg("parsing api version") + currversion = v120 } if currversion.LessThan(v120) {