Skip to content
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
6 changes: 3 additions & 3 deletions cmd/collectors/commonutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func InvokeRestCall(client *rest.Client, href string) ([]gjson.Result, error) {
}

func TruncateURL(href string) string {
indexOfQuestionMark := strings.Index(href, "?")
if indexOfQuestionMark == -1 {
before, _, found := strings.Cut(href, "?")
if !found {
return href
}
return href[:indexOfQuestionMark] + "..."
return before + "..."
}

func GetClusterTime(client *rest.Client, returnTimeOut *int, logger *slog.Logger) (time.Time, error) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/collectors/restperf/plugins/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,8 @@ func (d *Disk) calculateEnvironmentMetrics(data *matrix.Matrix) {
shelfEnvironmentMetricMap := make(map[string]*shelfEnvironmentMetric)
for _, o := range d.shelfData {
for k, instance := range o.GetInstances() {
firstInd := strings.Index(k, "#")
iKey, _, _ := strings.Cut(k, "#")
lastInd := strings.LastIndex(k, "#")
iKey := k[:firstInd]
iKey2 := k[lastInd+1:]
if _, ok := shelfEnvironmentMetricMap[iKey]; !ok {
shelfEnvironmentMetricMap[iKey] = &shelfEnvironmentMetric{key: iKey, ambientTemperature: []float64{}, nonAmbientTemperature: []float64{}, fanSpeed: []float64{}}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ func newMetric(n ast.Node, parents []string) Metric {
}

func trimComment(text string) string {
lastSink := strings.Index(text, "#")
if lastSink > -1 {
return strings.TrimSpace(text[:lastSink])
before, _, found := strings.Cut(text, "#")
if found {
return strings.TrimSpace(before)
}
return strings.TrimSpace(text)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,19 +591,19 @@ func visitTemplates(t *testing.T, eachTemplate func(path string, model Model), d

func collectorPath(path string) string {
const conf string = "conf/"
index := strings.Index(path, conf)
if index > 0 {
splits := strings.Split(path[index+len(conf):], "/")
before, after, found := strings.Cut(path, conf)
if found && before != "" {
splits := strings.Split(after, "/")
return splits[0]
}
return path
}

func shortPath(path string) string {
const conf string = "conf/"
index := strings.Index(path, conf)
if index > 0 {
return path[index+len(conf):]
before, after, found := strings.Cut(path, conf)
if found && before != "" {
return after
}
return path
}
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/goccy/go-yaml v1.19.0 h1:EmkZ9RIsX+Uq4DYFowegAuJo8+xdX3T/2dwNPXbxEYE=
github.com/goccy/go-yaml v1.19.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
Expand All @@ -25,16 +23,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
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/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
12 changes: 10 additions & 2 deletions integration/test/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ func TestPollerMetrics(t *testing.T) {
if strings.HasPrefix(row, "#") {
continue
}
openBracket := strings.Index(row, "{")
firstSpace := strings.Index(row, " ")
before, _, foundBracket := strings.Cut(row, "{")
openBracket := -1
if foundBracket {
openBracket = len(before)
}
beforeSpace, _, foundSpace := strings.Cut(row, " ")
firstSpace := -1
if foundSpace {
firstSpace = len(beforeSpace)
}
if openBracket == -1 {
// this means the metric has this form
// metric_without_labels 12.47
Expand Down
6 changes: 3 additions & 3 deletions pkg/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/goccy/go-yaml/parser"
"github.com/netapp/harvest/v2/pkg/errs"
"github.com/netapp/harvest/v2/pkg/tree/node"
"github.com/netapp/harvest/v2/pkg/tree/xml"
"github.com/netapp/harvest/v2/pkg/tree/treexml"
"os"
)

Expand Down Expand Up @@ -82,11 +82,11 @@ func isScalar(n ast.Node) bool {
}

func LoadXML(data []byte) (*node.Node, error) {
return xml.Load(data)
return treexml.Load(data)
}

func DumpXML(n *node.Node) ([]byte, error) {
return xml.Dump(n)
return treexml.Dump(n)
}

func ImportXML(filepath string) (*node.Node, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/tree/xml/xml.go → pkg/tree/treexml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright NetApp Inc, 2021 All rights reserved
*/

package xml
package treexml

import (
"bytes"
Expand Down
Loading