Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: bump go #3106

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .harvest.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GO_VERSION=1.22.6
GO_VERSION=1.23.0
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 " _ _ _ ___ __ "
Expand All @@ -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} ./...
Expand Down
4 changes: 3 additions & 1 deletion cmd/collectors/ems/templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion cmd/collectors/rest/plugins/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion cmd/collectors/rest/templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions cmd/collectors/restperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, "|"))

Expand Down
5 changes: 2 additions & 3 deletions cmd/collectors/zapiperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/harvest/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/poller/plugin/aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions cmd/poller/plugin/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down
14 changes: 4 additions & 10 deletions cmd/tools/generate/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, "#")
Expand All @@ -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, "#")
Expand All @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
15 changes: 5 additions & 10 deletions cmd/tools/rest/swag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand All @@ -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=
Expand Down
Loading