Skip to content

Commit

Permalink
fix: linter updates
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Saieva <[email protected]>
  • Loading branch information
Anthony Saieva committed Apr 11, 2024
1 parent 73ab40f commit cf0e2b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
23 changes: 6 additions & 17 deletions core/policyengine/source/otel/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ func NewOperations() source.Operations[*ResourceLogs] {
}

func getAllAttributes(rl *ResourceLogs) []*KeyValue {
// all resource logs attributes
//TODO hardcode other values
allAttrs := rl.Resource.Attributes
scopeLogs := rl.ScopeLogs

Expand Down Expand Up @@ -54,7 +52,6 @@ func (ops *Operations) Exists(attr string) (policy.Criterion[*ResourceLogs], err
}

func (ops *Operations) compareHelper(lattr string, rattr string, op source.Operator, kvs []*KeyValue) bool {
operator := OTEPOperator{}
for _, a := range kvs {
if a.Key != lattr {
continue
Expand All @@ -63,22 +60,22 @@ func (ops *Operations) compareHelper(lattr string, rattr string, op source.Opera
switch v := val.(type) {
case *StringValue:
strVal := v.StringValue
return operator.doStringComparison(strVal, rattr, op)
return (&OTEPOperator{}).doStringComparison(strVal, rattr, op)
case *ArrayValue:
// arrVal := v.ArrayValue
return operator.doArrayComparison(v, rattr, op)
return (&OTEPOperator{}).doArrayComparison(v, rattr, op)
case *BoolValue:
boolVal := v.BoolValue
return operator.doBooleanComparison(boolVal, rattr, op)
return (&OTEPOperator{}).doBooleanComparison(boolVal, rattr, op)
case *BytesValue:
bytVal := v.BytesValue
return operator.doBytesComparison(bytVal, rattr, op)
return (&OTEPOperator{}).doBytesComparison(bytVal, rattr, op)
case *DoubleValue:
dblVal := v.DoubleValue
return operator.doDoubleComparison(dblVal, rattr, op)
return (&OTEPOperator{}).doDoubleComparison(dblVal, rattr, op)
case *IntValue:
intVal := v.IntValue
return operator.doIntComparison(intVal, rattr, op)
return (&OTEPOperator{}).doIntComparison(intVal, rattr, op)
case *KvListValue:
kvListVal := v.KvlistValue.Values
return ops.compareHelper(lattr, rattr, op, kvListVal)
Expand All @@ -87,14 +84,6 @@ func (ops *Operations) compareHelper(lattr string, rattr string, op source.Opera
return false
}

// func isStringOperation(op source.Operator) bool {
// switch op {
// case source.Contains, source.IContains, source.Startswith, source.Endswith, source.IStartswith, source.IEndswith, source.IEq:
// return true
// }
// return false
// }

func (ops *Operations) Compare(lattr string, rattr string, op source.Operator) (policy.Criterion[*ResourceLogs], error) {
//TODO check if rattr is literal or in rule
f := func(rl *ResourceLogs) bool {
Expand Down
5 changes: 4 additions & 1 deletion driver/otel/kafkadriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ func (s *KafkaDriver) Init(pipeline plugins.SFPipeline, config map[string]interf
}

s.consumer = consumer
s.consumer.SubscribeTopics(topicsList, nil)
err = s.consumer.SubscribeTopics(topicsList, nil)
if err != nil {
return fmt.Errorf("unable to subscribe to topics")
}

// set the encoding of the events read off of kafka
enc, ok := config["encoding"]
Expand Down

0 comments on commit cf0e2b5

Please sign in to comment.