Skip to content

Commit

Permalink
Check all errors and remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyTetrahedron committed Nov 15, 2023
1 parent 3402aa6 commit f680ef2
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"regexp"
"time"

"github.com/appuio/appuio-cloud-reporting/pkg/odoo"
Expand Down Expand Up @@ -131,15 +130,21 @@ func processSample(ctx context.Context, odooClient OdooClient, args ReportArgs,
return nil, err
}
instanceStr := ""
json.Unmarshal([]byte(instance), &instanceStr)
err = json.Unmarshal([]byte(instance), &instanceStr)
if err != nil {
return nil, err
}

var groupStr string
if args.ItemGroupDescriptionJsonnet != "" {
group, err := vm.EvaluateAnonymousSnippet("group.json", args.ItemGroupDescriptionJsonnet)
if err != nil {
return nil, err
}
json.Unmarshal([]byte(group), &groupStr)
err = json.Unmarshal([]byte(group), &groupStr)
if err != nil {
return nil, err
}
}

var descriptionStr string
Expand All @@ -148,7 +153,10 @@ func processSample(ctx context.Context, odooClient OdooClient, args ReportArgs,
if err != nil {
return nil, err
}
json.Unmarshal([]byte(description), &descriptionStr)
err = json.Unmarshal([]byte(description), &descriptionStr)
if err != nil {
return nil, err
}
}

timerange := odoo.Timerange{
Expand All @@ -170,21 +178,6 @@ func processSample(ctx context.Context, odooClient OdooClient, args ReportArgs,
return &record, nil
}

func extractTemplateVars(args ReportArgs) []string {
// given all the patterns, return list of template variables
regex := regexp.MustCompile(`%\((\w+)\)s`)
searchString := args.InstanceJsonnet + ":" + args.ItemGroupDescriptionJsonnet + ":" + args.ItemDescriptionJsonnet
matches := regex.FindAllStringSubmatch(searchString, -1)

vars := make([]string, len(matches))

for i := 0; i < len(matches); i++ {
vars[i] = matches[i][1]
}

return vars
}

func getMetricLabel(m model.Metric, name string) (model.LabelValue, error) {
value, ok := m[model.LabelName(name)]
if !ok {
Expand Down

0 comments on commit f680ef2

Please sign in to comment.