Skip to content

Commit

Permalink
patch - tracing-alert-filter bug-fixing (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrNovo authored Jul 6, 2023
1 parent b519e54 commit 420e5de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions apis/coralogix/v1alpha1/alert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,17 @@ func expandTracingAlert(tracingFilters *TracingFilters) *alerts.TracingAlert {
}

func expandFiltersData(applications, subsystems, services []string) []*alerts.FilterData {
result := make([]*alerts.FilterData, 0, len(applications)+len(subsystems)+len(services))
result = append(result, expandSpecificFilter("applicationName", applications))
result = append(result, expandSpecificFilter("subsystemName", subsystems))
result = append(result, expandSpecificFilter("serviceName", services))
result := make([]*alerts.FilterData, 0)
if len(applications) != 0 {
result = append(result, expandSpecificFilter("applicationName", applications))
}
if len(subsystems) != 0 {
result = append(result, expandSpecificFilter("subsystemName", subsystems))
}
if len(services) != 0 {
result = append(result, expandSpecificFilter("serviceName", services))
}

return result
}

Expand Down Expand Up @@ -648,7 +655,7 @@ func expandSpecificFilter(filterName string, values []string) *alerts.FilterData
}

func expandFilter(filterString string) (operator, filterValue string) {
operator, filterValue = "Equals", filterString
operator, filterValue = "equals", filterString
if strings.HasPrefix(filterValue, "filter:") {
arr := strings.SplitN(filterValue, ":", 3)
operator, filterValue = arr[1], arr[2]
Expand Down
2 changes: 1 addition & 1 deletion controllers/alphacontrollers/alert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ func flattenTracingFilter(filters []*alerts.Filters) []string {
for _, f := range filters {
values := f.GetValues()
switch operator := f.GetOperator(); operator {
case "contains", "startsWith", "endsWith":
case "notEquals", "contains", "startsWith", "endsWith":
for i, val := range values {
values[i] = fmt.Sprintf("filter:%s:%s", operator, val)
}
Expand Down

0 comments on commit 420e5de

Please sign in to comment.