Add custom mapping related columns to http_integrations
What does this MR do?
Contributes to #262707 (closed)
Adds payload_example
and payload_attribute_mapping
columns to alert_management_http_integration
table.
The columns are intended for storing the custom mapping related information per HTTP integration for alerts.
The payload_example
is going to contain an example of an alert payload which is going to be sent to the alert's endpoint of a particular HTTP Integration.
It should be similar (or close) to the payload we store in the alert_management_alerts.payload
.
It is a custom field populated by a user with maintainer (and above) permissions.
The HTTP Integrations feature allows having one HTTP Integrations for licenses below GitLab Premium and several for licenses above GitLab Premium.
It can contain a lengthy JSON, but we are going to limit it to 1 MByte.
The payload_attribute_mapping
column is going to contain a mapping between an alert attributes we want to display on an alert's page and their paths in the alert's payload.
Can have the following structure:
payload_example
:
{
"alert": {
"name": "Example",
"desc": "An alert example",
},
"created_at": "2019-12-14T14:15:16Z"
}
payload_attribute_mapping
:
{
"title": { "type": "string", "path": ["alert", "name"] },
"description": { "type": "string", "path": ["alert", "desc"] },
"start_time": { "type": "datetime", "path": ["created_at"] }
}
We are not going to search by payload_example
, nor by payload_attributes_mapping
, thus there is no need to have indexes for these columns.
Migration output
→ be rake db:migrate
== 20201214113729 AddCustomMappingColumnsToHttpIntegrations: migrating ========
-- add_column(:alert_management_http_integrations, :payload_example, :jsonb, {:null=>false, :default=>{}})
-> 0.0050s
-- add_column(:alert_management_http_integrations, :payload_attribute_mapping, :jsonb, {:null=>false, :default=>{}})
-> 0.0006s
== 20201214113729 AddCustomMappingColumnsToHttpIntegrations: migrated (0.0058s)
→ be rake db:rollback
== 20201214113729 AddCustomMappingColumnsToHttpIntegrations: reverting ========
-- remove_column(:alert_management_http_integrations, :payload_attribute_mapping, :jsonb, {:null=>false, :default=>{}})
-> 0.0023s
-- remove_column(:alert_management_http_integrations, :payload_example, :jsonb, {:null=>false, :default=>{}})
-> 0.0003s
== 20201214113729 AddCustomMappingColumnsToHttpIntegrations: reverted (0.0063s)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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