Skip to content

Commit

Permalink
Merge branch 'primary' of github.com:telenornms/skogul into primary
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianLyng committed Nov 21, 2023
2 parents 96636eb + ac8d4a2 commit d87a715
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions transformer/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,33 @@ type Ban struct {

func (b *Ban) Transform(c *skogul.Container) error {
for pathKey, pathValue := range b.LookupData {
for metricKey, mi := range c.Metrics {
for k, mi := range c.Metrics {
var ptr interface{}

ptr, _ = jsonptr.Get(mi.Data, pathKey)

if ptr == pathValue {
c.Metrics = append(c.Metrics[:metricKey], c.Metrics[metricKey+1:]...)
if k == len(c.Metrics)-1 {
c.Metrics = c.Metrics[:k]
} else {
c.Metrics = append(c.Metrics[:k], c.Metrics[k+1:]...)
}
}
}
}

for pathKey, pathValue := range b.LookupMetadata {
for metricKey, mi := range c.Metrics {
for k, mi := range c.Metrics {
var ptr interface{}

ptr, _ = jsonptr.Get(mi.Metadata, pathKey)

if ptr == pathValue {
c.Metrics = append(c.Metrics[:metricKey], c.Metrics[metricKey+1:]...)
if k == len(c.Metrics)-1 {
c.Metrics = c.Metrics[:k]
} else {
c.Metrics = append(c.Metrics[:k], c.Metrics[k+1:]...)
}
continue
}
}
}
Expand Down

0 comments on commit d87a715

Please sign in to comment.