Skip to content

Commit

Permalink
Fix formatting in cast-transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianLyng committed Feb 27, 2023
1 parent 7f8916e commit 22bf7cc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions transformer/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
package transformer

import (
"encoding/json"
"fmt"
"math/big"
"net"
"strconv"
"encoding/json"

"github.com/telenornms/skogul"
)
Expand All @@ -41,15 +41,14 @@ type Cast struct {
MetadataFlatFloats []string `doc:"List of metadatafields that are floats which should be expressed as plain, non-exponential numbers in text. E.g.: Large serial numbers will be written as plain numbers, not 1.1231215e+10. If the field is a non-float, it will be left as is."`
MetadataIpToDec []string `doc:"List of metadatafields containing IP addresses that should be decimals"`
MetadataJson []string `doc:"List of fields that will be json-decoded. E.g.: Original value is encoded as text string, but contains json."`
MetadataTopJson string `doc:"Metadata-field containing text-encoded JSON which will replace all other metadata after being decoded."`
MetadataTopJson string `doc:"Metadata-field containing text-encoded JSON which will replace all other metadata after being decoded."`
DataStrings []string `doc:"List of datafields that should be strings"`
DataInts []string `doc:"List of datafields that should be integers"`
DataFloats []string `doc:"List of datafields that should be 64-bit floats"`
DataFlatFloats []string `doc:"List of metadatafields that are floats which should be expressed as plain, non-exponential numbers in text. E.g.: Large serial numbers will be written as plain numbers, not 1.1231215e+10. If the field is a non-float, it will be left as is."`
DataIpToDec []string `doc:"List of datafields containing IP addresses that should be decimals"`
DataJson []string `doc:"List of fields that will be json-decoded. E.g.: Original value is encoded as text string, but contains json."`
DataTopJson string `doc:"Data-field containing text-encoded JSON which will replace all other data after being decoded."`

DataTopJson string `doc:"Data-field containing text-encoded JSON which will replace all other data after being decoded."`
}

// Transform enforces the Cast rules
Expand All @@ -73,7 +72,7 @@ func (cast *Cast) Transform(c *skogul.Container) error {
}
var tmp interface{}
e := json.Unmarshal([]byte(tmp1), &tmp)
if e!= nil {
if e != nil {
return e
}

Expand All @@ -89,7 +88,7 @@ func (cast *Cast) Transform(c *skogul.Container) error {
}
var lol map[string]interface{}
e := json.Unmarshal([]byte(tmp1), &lol)
if e!= nil {
if e != nil {
return e
}
c.Metrics[mi].Data = lol
Expand All @@ -104,7 +103,7 @@ func (cast *Cast) Transform(c *skogul.Container) error {
}
var tmp interface{}
e := json.Unmarshal([]byte(tmp1), &tmp)
if e!= nil {
if e != nil {
return e
}

Expand All @@ -120,15 +119,14 @@ func (cast *Cast) Transform(c *skogul.Container) error {
}
var lol map[string]interface{}
e := json.Unmarshal([]byte(tmp1), &lol)
if e!= nil {
if e != nil {
return e
}
c.Metrics[mi].Metadata = lol

}
}


for _, value := range cast.DataFloats {
if c.Metrics[mi].Data[value] != nil {
_, ok := c.Metrics[mi].Data[value].(float64)
Expand Down

0 comments on commit 22bf7cc

Please sign in to comment.