diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 9051ae792..7c7ff6abd 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -295,35 +295,6 @@ func TemplateFn(n *node.Node, obj string) string { return fn } -// Returns a slice of keys in dot notation from json -func getFieldName(source string, parent string) []string { - res := make([]string, 0) - var arr map[string]gjson.Result - r := gjson.Parse(source) - switch { - case r.IsArray(): - newR := r.Get("0") - arr = newR.Map() - case r.IsObject(): - arr = r.Map() - default: - return []string{parent} - } - if len(arr) == 0 { - return []string{parent} - } - for key, val := range arr { - var temp []string - if parent == "" { - temp = getFieldName(val.Raw, key) - } else { - temp = getFieldName(val.Raw, parent+"."+key) - } - res = append(res, temp...) - } - return res -} - // PollCounter performs daily tasks such as updating the cluster info and caching href. func (r *Rest) PollCounter() (map[string]*matrix.Matrix, error) { diff --git a/cmd/collectors/rest/rest_test.go b/cmd/collectors/rest/rest_test.go index 77b35901b..600575faa 100644 --- a/cmd/collectors/rest/rest_test.go +++ b/cmd/collectors/rest/rest_test.go @@ -20,49 +20,6 @@ const ( pollerName = "test" ) -func Test_getFieldName(t *testing.T) { - - type test struct { - name string - source string - parent string - want int - } - - var tests = []test{ - { - name: "Test1", - source: readFile("testdata/cluster.json"), - parent: "", - want: 52, - }, - { - name: "Test2", - source: readFile("testdata/sample.json"), - parent: "", - want: 3, - }, - { - name: "Test3", - source: readFile("testdata/test.json"), - parent: "", - want: 9, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getFieldName(tt.source, tt.parent); len(got) != tt.want { - t.Errorf("length of output slice = %v, want %v", len(got), tt.want) - } - }) - } -} - -func readFile(path string) string { - b, _ := os.ReadFile(path) - return string(b) -} - var ( ms []*matrix.Matrix benchRest *Rest