diff --git a/.harvest.env b/.harvest.env index 9cf1bdacc..ac7c4a820 100644 --- a/.harvest.env +++ b/.harvest.env @@ -1 +1 @@ -GO_VERSION=1.22.6 \ No newline at end of file +GO_VERSION=1.23.0 \ No newline at end of file diff --git a/Makefile b/Makefile index 092d95755..eb58b3291 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ ifneq (,$(wildcard $(HARVEST_ENV))) endif help: ## Display this help - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-11s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) header: @echo " _ _ _ ___ __ " @@ -65,22 +65,22 @@ clean: ## Cleanup the project binary (bin) folders find ./bin -type f -not -name "*asup*" -exec rm -f {} +; \ fi -test: ## run tests +test: ## Run tests @echo "Testing" @# The ldflags force the old Apple linker to suppress ld warning messages on MacOS @# See https://github.com/golang/go/issues/61229#issuecomment-1988965927 @go test -ldflags=-extldflags=-Wl,-ld_classic -race -shuffle=on ./... -fmt: ## format the go source files +fmt: ## Format the go source files @echo "Formatting" @go fmt ./... -lint: ## run golangci-lint on the source files +lint: ## Run golangci-lint on the source files @echo "Linting" @go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} run ./... @cd integration && go mod tidy && go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} run ./... -govulncheck: ## run govulncheck on the source files +govulncheck: ## Run govulncheck on the source files @echo "Govulnchecking" @go run golang.org/x/vuln/cmd/govulncheck@${GOVULNCHECK_VERSION} ./... @cd integration && go mod tidy && go run golang.org/x/vuln/cmd/govulncheck@${GOVULNCHECK_VERSION} ./... diff --git a/cmd/collectors/ems/templating.go b/cmd/collectors/ems/templating.go index 3edba70d3..d2357b53d 100644 --- a/cmd/collectors/ems/templating.go +++ b/cmd/collectors/ems/templating.go @@ -4,6 +4,8 @@ import ( "github.com/netapp/harvest/v2/pkg/set" "github.com/netapp/harvest/v2/pkg/tree/node" "github.com/netapp/harvest/v2/pkg/util" + "maps" + "slices" "time" ) @@ -91,7 +93,7 @@ func (e *Ems) ParseExports(counter *node.Node, prop *emsProp) { // For bookend case, instanceKeys are replaced with bookendKeys if len(bookendKeys) > 0 { - sortedBookendKeys := util.GetSortedKeys(bookendKeys) + sortedBookendKeys := slices.Sorted(maps.Keys(bookendKeys)) // Append instance keys to ems prop for _, k := range sortedBookendKeys { prop.InstanceKeys = append(prop.InstanceKeys, bookendKeys[k]) diff --git a/cmd/collectors/rest/plugins/health/health_test.go b/cmd/collectors/rest/plugins/health/health_test.go index ff016e3b5..780d73f32 100644 --- a/cmd/collectors/rest/plugins/health/health_test.go +++ b/cmd/collectors/rest/plugins/health/health_test.go @@ -35,7 +35,7 @@ func TestEndPoll(t *testing.T) { // Check that resolutionData has the expected values resMat, ok := h.resolutionData[matName] if !ok { - t.Fatalf("expected resolutionData to have key " + matName) + t.Fatal("expected resolutionData to have key " + matName) } // Check the count of instances in the resolution matrix diff --git a/cmd/collectors/rest/templating.go b/cmd/collectors/rest/templating.go index 00187fee7..4096632a4 100644 --- a/cmd/collectors/rest/templating.go +++ b/cmd/collectors/rest/templating.go @@ -5,7 +5,9 @@ import ( "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/tree/node" "github.com/netapp/harvest/v2/pkg/util" + "maps" "regexp" + "slices" "strconv" "strings" "time" @@ -183,7 +185,7 @@ func (r *Rest) ParseRestCounters(counter *node.Node, prop *prop) { // populate prop.instanceKeys // sort keys by display name. This is needed to match counter and endpoints keys - keys := util.GetSortedKeys(instanceKeys) + keys := slices.Sorted(maps.Keys(instanceKeys)) // Append instance keys to prop for _, k := range keys { diff --git a/cmd/collectors/restperf/plugins/disk/disk.go b/cmd/collectors/restperf/plugins/disk/disk.go index f57cf439e..ffa7819b7 100644 --- a/cmd/collectors/restperf/plugins/disk/disk.go +++ b/cmd/collectors/restperf/plugins/disk/disk.go @@ -9,7 +9,7 @@ import ( "github.com/netapp/harvest/v2/pkg/tree/node" "github.com/netapp/harvest/v2/pkg/util" "github.com/tidwall/gjson" - "golang.org/x/exp/maps" + "maps" "slices" "strings" "time" @@ -331,8 +331,7 @@ func (d *Disk) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util.M } if len(noSet) > 0 { - attributes := maps.Keys(noSet) - slices.Sort(attributes) + attributes := slices.Sorted(maps.Keys(noSet)) d.Logger.Warn().Strs("attributes", attributes).Msg("No instances") } diff --git a/cmd/collectors/restperf/restperf.go b/cmd/collectors/restperf/restperf.go index b0f210ed5..50b1ec66e 100644 --- a/cmd/collectors/restperf/restperf.go +++ b/cmd/collectors/restperf/restperf.go @@ -23,7 +23,7 @@ import ( "github.com/netapp/harvest/v2/pkg/util" "github.com/rs/zerolog" "github.com/tidwall/gjson" - "golang.org/x/exp/maps" + "maps" "path" "regexp" "slices" @@ -707,8 +707,7 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) { var filter []string // Sort filters so that the href is deterministic - metrics := maps.Keys(r.Prop.Metrics) - slices.Sort(metrics) + metrics := slices.Sorted(maps.Keys(r.Prop.Metrics)) filter = append(filter, "counters.name="+strings.Join(metrics, "|")) diff --git a/cmd/collectors/zapiperf/plugins/disk/disk.go b/cmd/collectors/zapiperf/plugins/disk/disk.go index 233136980..a3d207874 100644 --- a/cmd/collectors/zapiperf/plugins/disk/disk.go +++ b/cmd/collectors/zapiperf/plugins/disk/disk.go @@ -9,7 +9,7 @@ import ( "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/tree/node" "github.com/netapp/harvest/v2/pkg/util" - "golang.org/x/exp/maps" + "maps" "slices" "strconv" "strings" @@ -882,8 +882,7 @@ func (d *Disk) handleCMode(shelves []*node.Node) ([]*matrix.Matrix, error) { } if len(noSet) > 0 { - attributes := maps.Keys(noSet) - slices.Sort(attributes) + attributes := slices.Sorted(maps.Keys(noSet)) d.Logger.Warn().Strs("attributes", attributes).Msg("No instances") } diff --git a/cmd/harvest/version/version.go b/cmd/harvest/version/version.go index 6a2c6be3c..c3ef036b2 100644 --- a/cmd/harvest/version/version.go +++ b/cmd/harvest/version/version.go @@ -49,7 +49,7 @@ func Cmd() *cobra.Command { } func doVersion(cmd *cobra.Command, _ []string) { - fmt.Printf(cmd.Root().Version) + fmt.Print(cmd.Root().Version) checkLatest() } diff --git a/cmd/poller/plugin/aggregator/aggregator.go b/cmd/poller/plugin/aggregator/aggregator.go index eea4604a5..ddccebe02 100644 --- a/cmd/poller/plugin/aggregator/aggregator.go +++ b/cmd/poller/plugin/aggregator/aggregator.go @@ -10,8 +10,9 @@ import ( "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/matrix" "github.com/netapp/harvest/v2/pkg/util" - "golang.org/x/exp/maps" + "maps" "regexp" + "slices" "strings" ) @@ -162,7 +163,8 @@ func (a *Aggregator) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, * switch { case rule.allLabels: - objKey = strings.Join(maps.Values(instance.GetLabels()), ".") + values := slices.Collect(maps.Keys(instance.GetLabels())) + objKey = strings.Join(values, ".") case len(rule.includeLabels) != 0: objKey = objName for _, k := range rule.includeLabels { diff --git a/cmd/poller/plugin/changelog/changelog.go b/cmd/poller/plugin/changelog/changelog.go index a527d83be..b912430bf 100644 --- a/cmd/poller/plugin/changelog/changelog.go +++ b/cmd/poller/plugin/changelog/changelog.go @@ -6,7 +6,6 @@ import ( "github.com/netapp/harvest/v2/pkg/set" "github.com/netapp/harvest/v2/pkg/tree/yaml" "github.com/netapp/harvest/v2/pkg/util" - maps2 "golang.org/x/exp/maps" "maps" "strconv" "time" @@ -277,9 +276,9 @@ func (c *ChangeLog) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *u func (c *ChangeLog) CompareMetrics(curMat *matrix.Matrix) map[string]map[string]struct{} { metricChanges := make(map[string]map[string]struct{}) prevMat := c.previousData - met := maps2.Keys(c.previousData.GetMetrics()) + met := maps.Keys(c.previousData.GetMetrics()) - for _, metricKey := range met { + for metricKey := range met { prevMetric := prevMat.GetMetric(metricKey) curMetric := curMat.GetMetric(metricKey) for key, currInstance := range curMat.GetInstances() { diff --git a/cmd/tools/generate/counter.go b/cmd/tools/generate/counter.go index b56d89576..b95fb642e 100644 --- a/cmd/tools/generate/counter.go +++ b/cmd/tools/generate/counter.go @@ -11,9 +11,9 @@ import ( "github.com/netapp/harvest/v2/pkg/util" tw "github.com/netapp/harvest/v2/third_party/olekukonko/tablewriter" "github.com/tidwall/gjson" - "golang.org/x/exp/maps" "gopkg.in/yaml.v3" "log" + "maps" "os" "os/exec" "path/filepath" @@ -737,7 +737,7 @@ var reRemove = regexp.MustCompile(`NFSv\d+\.\d+`) func mergeCounters(restCounters map[string]Counter, zapiCounters map[string]Counter) map[string]Counter { // handle special counters - restKeys := sortedKeys(restCounters) + restKeys := slices.Sorted(maps.Keys(restCounters)) for _, k := range restKeys { v := restCounters[k] hashIndex := strings.Index(k, "#") @@ -755,7 +755,7 @@ func mergeCounters(restCounters map[string]Counter, zapiCounters map[string]Coun } } - zapiKeys := sortedKeys(zapiCounters) + zapiKeys := slices.Sorted(maps.Keys(zapiCounters)) for _, k := range zapiKeys { v := zapiCounters[k] hashIndex := strings.Index(k, "#") @@ -774,7 +774,7 @@ func mergeCounters(restCounters map[string]Counter, zapiCounters map[string]Coun } // special keys are deleted hence sort again - zapiKeys = sortedKeys(zapiCounters) + zapiKeys = slices.Sorted(maps.Keys(zapiCounters)) for _, k := range zapiKeys { v := zapiCounters[k] if v1, ok := restCounters[k]; ok { @@ -796,12 +796,6 @@ func mergeCounters(restCounters map[string]Counter, zapiCounters map[string]Coun return restCounters } -func sortedKeys(m map[string]Counter) []string { - keys := maps.Keys(m) - slices.Sort(keys) - return keys -} - func processRestPerfCounters(path string, client *rest.Client) map[string]Counter { var ( records []gjson.Result diff --git a/cmd/tools/generate/generate.go b/cmd/tools/generate/generate.go index f307c3365..db4137314 100644 --- a/cmd/tools/generate/generate.go +++ b/cmd/tools/generate/generate.go @@ -285,12 +285,12 @@ func generateDocker(kind int) { } if kind == harvest { - _, _ = fmt.Fprintf(os.Stderr, + _, _ = fmt.Fprint(os.Stderr, "Start containers with:\n"+ color.Colorize("docker compose -f "+opts.outputPath+" up -d --remove-orphans\n", color.Green)) } if kind == full { - _, _ = fmt.Fprintf(os.Stderr, + _, _ = fmt.Fprint(os.Stderr, "Start containers with:\n"+ color.Colorize("docker compose -f prom-stack.yml -f "+opts.outputPath+" up -d --remove-orphans\n", color.Green)) } diff --git a/cmd/tools/rest/swag.go b/cmd/tools/rest/swag.go index 401fcb9b5..e18cc59e3 100644 --- a/cmd/tools/rest/swag.go +++ b/cmd/tools/rest/swag.go @@ -11,13 +11,14 @@ import ( "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/third_party/bbrks/wrap/v2" tw "github.com/netapp/harvest/v2/third_party/olekukonko/tablewriter" - "golang.org/x/exp/maps" "gopkg.in/yaml.v3" "html" "io" + "maps" "net/url" "os" "regexp" + "slices" "sort" "strconv" "strings" @@ -79,7 +80,7 @@ func showModels(a Args, ontapSwag ontap) { } seen := map[string]interface{}{} var collected []model - for _, name := range sortApis(ontapSwag.collectionsApis) { + for _, name := range slices.Sorted(maps.Keys(ontapSwag.collectionsApis)) { pathItem := ontapSwag.collectionsApis[name] if compile.MatchString(name) { if pathItem.Get.OperationProps.Responses != nil { @@ -203,12 +204,6 @@ func printProperty(args propArgs) { } } -func sortApis(schema map[string]spec.PathItem) []string { - keys := maps.Keys(schema) - sort.Strings(keys) - return keys -} - func showParams(a Args, ontapSwag ontap) { compile, err := regexp.Compile(a.API) if err != nil { @@ -217,7 +212,7 @@ func showParams(a Args, ontapSwag ontap) { } w := wrap.NewWrapper() w.StripTrailingNewline = true - for _, name := range sortApis(ontapSwag.collectionsApis) { + for _, name := range slices.Sorted(maps.Keys(ontapSwag.collectionsApis)) { pathItem := ontapSwag.collectionsApis[name] table := newTable(" ", "type", "field", "description") table.SetColMinWidth(3, descriptionWidth) @@ -340,7 +335,7 @@ func readSwagger(args Args) (ontap, error) { } } } - names := sortApis(collectionsApis) + names := slices.Sorted(maps.Keys(collectionsApis)) return ontap{apis: names, swagger: ontapSwag, collectionsApis: collectionsApis}, nil } diff --git a/go.mod b/go.mod index 7cf2e8d3c..08964925c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/netapp/harvest/v2 -go 1.22 +go 1.23 require ( github.com/go-openapi/spec v0.21.0 @@ -11,7 +11,6 @@ require ( github.com/spf13/cobra v1.8.1 github.com/tidwall/gjson v1.17.3 github.com/zekroTJA/timedmap/v2 v2.0.0 - golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa golang.org/x/sys v0.24.0 golang.org/x/term v0.23.0 golang.org/x/text v0.17.0 diff --git a/go.sum b/go.sum index cea01d09d..1c46ed02d 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= -github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shirou/gopsutil/v4 v4.24.7 h1:V9UGTK4gQ8HvcnPKf6Zt3XHyQq/peaekfxpJ2HSocJk= github.com/shirou/gopsutil/v4 v4.24.7/go.mod h1:0uW/073rP7FYLOkvxolUQM5rMOLTNmRXnFKafpb71rw= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= @@ -63,8 +61,6 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -80,28 +76,16 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zekroTJA/timedmap/v2 v2.0.0 h1:Bo9oq8AExd0GuDFbcPXm3xoidUAtrnNsZN1d1Hc3PvY= github.com/zekroTJA/timedmap/v2 v2.0.0/go.mod h1:xHDLg687zASqLBJqoysF+WORHxL/kYNphVD36CRJxhM= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/integration/go.mod b/integration/go.mod index 2de4d5feb..794785b6a 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -1,6 +1,8 @@ module github.com/Netapp/harvest-automation -go 1.22 +go 1.23 + +toolchain go1.23.0 replace github.com/netapp/harvest/v2 => ../ @@ -8,8 +10,8 @@ require ( github.com/carlmjohnson/requests v0.23.5 github.com/netapp/harvest/v2 v2.0.0-20240618123731-00a4fa826af5 github.com/rs/zerolog v1.33.0 - github.com/tidwall/gjson v1.17.1 - golang.org/x/text v0.16.0 + github.com/tidwall/gjson v1.17.3 + golang.org/x/text v0.17.0 ) require ( @@ -26,7 +28,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/shirou/gopsutil/v4 v4.24.6 // indirect + github.com/shirou/gopsutil/v4 v4.24.7 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -35,9 +37,8 @@ require ( github.com/tklauser/go-sysconf v0.3.14 // indirect github.com/tklauser/numcpus v0.8.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.24.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/integration/go.sum b/integration/go.sum index 2dd61acf3..d5cbe598e 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -49,8 +49,8 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= -github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shirou/gopsutil/v4 v4.24.7 h1:V9UGTK4gQ8HvcnPKf6Zt3XHyQq/peaekfxpJ2HSocJk= +github.com/shirou/gopsutil/v4 v4.24.7/go.mod h1:0uW/073rP7FYLOkvxolUQM5rMOLTNmRXnFKafpb71rw= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -61,8 +61,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= +github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -74,8 +74,6 @@ github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYg github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -84,10 +82,10 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/integration/test/counter_test.go b/integration/test/counter_test.go index 85cc8b740..faa57be43 100644 --- a/integration/test/counter_test.go +++ b/integration/test/counter_test.go @@ -51,7 +51,7 @@ func TestCounters(t *testing.T) { pollerName := "dc1" if poller, err = conf.PollerNamed(pollerName); err != nil { - log.Fatal().Err(err).Str("poller", pollerName).Msgf("") + log.Fatal().Err(err).Str("poller", pollerName).Send() } if poller.Addr == "" { log.Fatal().Str("poller", pollerName).Msg("Address is empty") @@ -131,7 +131,7 @@ func visitRestTemplates(dir string, client *rest2.Client, eachTemp func(path str }) if err != nil { - log.Fatal().Err(err).Msgf("failed to walk directory: %s", dir) + log.Fatal().Err(err).Str("dir", dir).Msg("failed to walk directory: %s") } return result diff --git a/integration/test/metric_test.go b/integration/test/metric_test.go index 4d0e0e335..cc93648f4 100644 --- a/integration/test/metric_test.go +++ b/integration/test/metric_test.go @@ -96,7 +96,7 @@ func TestPollerMetrics(t *testing.T) { } sort.Strings(duplicateMetrics) for _, dupMetric := range duplicateMetrics { - t.Errorf(dupMetric) + t.Error(dupMetric) } } diff --git a/pkg/matrix/matrix.go b/pkg/matrix/matrix.go index 1881a5db1..329d0fd3a 100644 --- a/pkg/matrix/matrix.go +++ b/pkg/matrix/matrix.go @@ -15,7 +15,8 @@ import ( "github.com/netapp/harvest/v2/pkg/errs" "github.com/netapp/harvest/v2/pkg/logging" "github.com/netapp/harvest/v2/pkg/tree/node" - "golang.org/x/exp/maps" + "maps" + "slices" "strings" ) @@ -256,7 +257,7 @@ func (m *Matrix) PurgeInstances() { } func (m *Matrix) GetInstanceKeys() []string { - return maps.Keys(m.instances) + return slices.Collect(maps.Keys(m.instances)) } func (m *Matrix) NewInstance(key string) (*Instance, error) { diff --git a/pkg/matrix/metric.go b/pkg/matrix/metric.go index 815e44126..323463b2e 100644 --- a/pkg/matrix/metric.go +++ b/pkg/matrix/metric.go @@ -135,7 +135,7 @@ func (m *Metric) GetLabels() map[string]string { } func (m *Metric) HasLabels() bool { - return m.labels != nil && len(m.labels) > 0 + return len(m.labels) > 0 } func (m *Metric) GetRecords() []bool { diff --git a/pkg/util/util.go b/pkg/util/util.go index fb4f8ad97..b9006f4b5 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -10,7 +10,6 @@ import ( "github.com/netapp/harvest/v2/third_party/go-version" "github.com/rs/zerolog" "github.com/shirou/gopsutil/v4/process" - "golang.org/x/exp/maps" "golang.org/x/sys/unix" "gopkg.in/yaml.v3" "net" @@ -19,7 +18,6 @@ import ( "os" "regexp" "slices" - "sort" "strconv" "strings" ) @@ -417,12 +415,6 @@ func HasDuplicates(slice []string) bool { return false } -func GetSortedKeys(m map[string]string) []string { - keys := maps.Keys(m) - sort.Strings(keys) - return keys -} - func GetURLWithoutHost(r *http.Request) string { urlWithoutHost := r.URL.Path if r.URL.RawQuery != "" { diff --git a/vendor/golang.org/x/exp/LICENSE b/vendor/golang.org/x/exp/LICENSE deleted file mode 100644 index 2a7cf70da..000000000 --- a/vendor/golang.org/x/exp/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright 2009 The Go Authors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google LLC nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/exp/PATENTS b/vendor/golang.org/x/exp/PATENTS deleted file mode 100644 index 733099041..000000000 --- a/vendor/golang.org/x/exp/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/exp/maps/maps.go b/vendor/golang.org/x/exp/maps/maps.go deleted file mode 100644 index ecc0dabb7..000000000 --- a/vendor/golang.org/x/exp/maps/maps.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package maps defines various functions useful with maps of any type. -package maps - -// Keys returns the keys of the map m. -// The keys will be in an indeterminate order. -func Keys[M ~map[K]V, K comparable, V any](m M) []K { - r := make([]K, 0, len(m)) - for k := range m { - r = append(r, k) - } - return r -} - -// Values returns the values of the map m. -// The values will be in an indeterminate order. -func Values[M ~map[K]V, K comparable, V any](m M) []V { - r := make([]V, 0, len(m)) - for _, v := range m { - r = append(r, v) - } - return r -} - -// Equal reports whether two maps contain the same key/value pairs. -// Values are compared using ==. -func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || v1 != v2 { - return false - } - } - return true -} - -// EqualFunc is like Equal, but compares values using eq. -// Keys are still compared with ==. -func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || !eq(v1, v2) { - return false - } - } - return true -} - -// Clear removes all entries from m, leaving it empty. -func Clear[M ~map[K]V, K comparable, V any](m M) { - for k := range m { - delete(m, k) - } -} - -// Clone returns a copy of m. This is a shallow clone: -// the new keys and values are set using ordinary assignment. -func Clone[M ~map[K]V, K comparable, V any](m M) M { - // Preserve nil in case it matters. - if m == nil { - return nil - } - r := make(M, len(m)) - for k, v := range m { - r[k] = v - } - return r -} - -// Copy copies all key/value pairs in src adding them to dst. -// When a key in src is already present in dst, -// the value in dst will be overwritten by the value associated -// with the key in src. -func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { - for k, v := range src { - dst[k] = v - } -} - -// DeleteFunc deletes any key/value pairs from m for which del returns true. -func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) { - for k, v := range m { - if del(k, v) { - delete(m, k) - } - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d3398b4ac..e36d7a790 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -94,9 +94,6 @@ github.com/yusufpapurcu/wmi # github.com/zekroTJA/timedmap/v2 v2.0.0 ## explicit; go 1.19 github.com/zekroTJA/timedmap/v2 -# golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa -## explicit; go 1.20 -golang.org/x/exp/maps # golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/plan9