Skip to content

POC/WIP/Garbage: Rearrange presenting layer of AlertMangement::Alerts

What does this MR do?

I am so overwhelmed by the presentation classes around alerts. I never have any idea where things should live. I would like that to be better.

DISCLAIMER: This MR is very incomplete and broken, but is an idea of a direction we could go in that I think could help.

Proposed architecture:

  • A Gitlab::AlertManagement::Payload::Base defines an api by which any alert payload content is accessible. Any payload field we expect to interact with (beyond simply displaying it or passing it through to FE), should be defined as part of the base class.
  • Subclasses of Payload::Base define how to access fields from the payload or find corresponding DB records based on the source of the alert (prometheus/generic/etc).
  • Example use-case: display an alert in the UI. In this scenario, payload attributes should be accessed through the #parsed_payload field on an AlertManagement::Alert.
  • Example use-case: create a new AlertManagement::Alert from an incoming notification. Use the new_from_payload class method on AlertMangement::Alert to instantiate an instance of the class with attributes populated from the payload.
  • Example use-case: send an email based on an alert. For presentational elements (such as formatting strings), use the AlertManagement::AlertPresenter, accessible through the #present method on AlertManagement::Alert.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Merge request reports