Skip to content

Commit

Permalink
[refactor] alert reconciler
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <[email protected]>
  • Loading branch information
nicolastakashi committed Apr 30, 2024
1 parent faf0bfb commit e0dd1eb
Show file tree
Hide file tree
Showing 8 changed files with 705 additions and 474 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- name: Install Go
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Run build
run: make build
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Generate docs
run: make generate-api-docs
- name: Check for changes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Running operator and Tests
env:
CORALOGIX_REGION: ${{ secrets.CORALOGIX_REGION }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CRDOC ?= $(LOCALBIN)/crdoc

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CONTROLLER_TOOLS_VERSION ?= v0.15.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
38 changes: 14 additions & 24 deletions apis/coralogix/v1alpha1/alert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,36 +153,26 @@ type AlertSpec struct {
AlertType AlertType `json:"alertType"`
}

func (in *AlertSpec) ExtractCreateAlertRequest(ctx context.Context) (*alerts.CreateAlertRequest, error) {
enabled := wrapperspb.Bool(in.Active)
name := wrapperspb.String(in.Name)
description := wrapperspb.String(in.Description)
severity := AlertSchemaSeverityToProtoSeverity[in.Severity]
metaLabels := expandMetaLabels(in.Labels)
expirationDate := expandExpirationDate(in.ExpirationDate)
showInInsight := expandShowInInsight(in.ShowInInsight)
notificationGroups, err := expandNotificationGroups(ctx, in.NotificationGroups)
func (a *Alert) ExtractCreateAlertRequest(ctx context.Context) (*alerts.CreateAlertRequest, error) {
notificationGroups, err := expandNotificationGroups(ctx, a.Spec.NotificationGroups)
if err != nil {
return nil, err
}
payloadFilters := utils.StringSliceToWrappedStringSlice(in.PayloadFilters)
activeWhen := expandActiveWhen(in.Scheduling)
alertTypeParams := expandAlertType(in.AlertType)

return &alerts.CreateAlertRequest{
Name: name,
Description: description,
IsActive: enabled,
Severity: severity,
MetaLabels: metaLabels,
Expiration: expirationDate,
ShowInInsight: showInInsight,
IsActive: wrapperspb.Bool(a.Spec.Active),
Name: wrapperspb.String(a.Spec.Name),
Description: wrapperspb.String(a.Spec.Description),
Severity: AlertSchemaSeverityToProtoSeverity[a.Spec.Severity],
MetaLabels: expandMetaLabels(a.Spec.Labels),
Expiration: expandExpirationDate(a.Spec.ExpirationDate),
ShowInInsight: expandShowInInsight(a.Spec.ShowInInsight),
NotificationGroups: notificationGroups,
NotificationPayloadFilters: payloadFilters,
ActiveWhen: activeWhen,
Filters: alertTypeParams.filters,
Condition: alertTypeParams.condition,
TracingAlert: alertTypeParams.tracingAlert,
NotificationPayloadFilters: utils.StringSliceToWrappedStringSlice(a.Spec.PayloadFilters),
ActiveWhen: expandActiveWhen(a.Spec.Scheduling),
Filters: expandAlertType(a.Spec.AlertType).filters,
Condition: expandAlertType(a.Spec.AlertType).condition,
TracingAlert: expandAlertType(a.Spec.AlertType).tracingAlert,
}, nil
}

Expand Down
Loading

0 comments on commit e0dd1eb

Please sign in to comment.