From f50b7a52f9b7bafa31aee7144f2cd8c54e1b187e Mon Sep 17 00:00:00 2001 From: hardikl Date: Tue, 3 Oct 2023 13:48:00 +0530 Subject: [PATCH] feat: handle review comments --- .../rest/plugins/netroute/netroute.go | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/cmd/collectors/rest/plugins/netroute/netroute.go b/cmd/collectors/rest/plugins/netroute/netroute.go index cbb9e8025..f90fae9ac 100644 --- a/cmd/collectors/rest/plugins/netroute/netroute.go +++ b/cmd/collectors/rest/plugins/netroute/netroute.go @@ -76,25 +76,23 @@ func (n *NetRoute) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, err names := interfacesList.Get("name").Array() address := interfacesList.Get("address").Array() - if names != nil && address != nil { - if len(names) == len(address) { - for i, name := range names { - index := strings.Join([]string{cluster, strconv.Itoa(count)}, "_") - interfaceInstance, err := n.data.NewInstance(index) - if err != nil { - n.Logger.Error().Err(err).Str("add instance failed for instance key", key).Send() - return nil, err - } - - for _, l := range instanceLabels { - interfaceInstance.SetLabel(l, instance.GetLabel(l)) - } - interfaceInstance.SetLabel("index", index) - interfaceInstance.SetLabel("address", address[i].String()) - interfaceInstance.SetLabel("name", name.String()) - interfaceInstance.SetLabel("route_uuid", routeID) - count++ + if len(names) == len(address) { + for i, name := range names { + index := strings.Join([]string{cluster, strconv.Itoa(count)}, "_") + interfaceInstance, err := n.data.NewInstance(index) + if err != nil { + n.Logger.Error().Err(err).Str("add instance failed for instance key", key).Send() + return nil, err } + + for _, l := range instanceLabels { + interfaceInstance.SetLabel(l, instance.GetLabel(l)) + } + interfaceInstance.SetLabel("index", index) + interfaceInstance.SetLabel("address", address[i].String()) + interfaceInstance.SetLabel("name", name.String()) + interfaceInstance.SetLabel("route_uuid", routeID) + count++ } } }