add_alertmanager.go
014_add_alertmanager.go - Overview
-
Overview This file defines a SQL migration to add Alertmanager configurations and states to the database, including handling notification channels and converting MS Teams configurations.
-
Detailed Documentation
addAlertmanager
- Purpose: Struct to hold the sqlstore instance for the migration.
- Parameters: None
- Returns: None
NewAddAlertmanagerFactory
- Purpose: Creates a new factory for the
addAlertmanager
migration. - Parameters:
store
(sqlstore.SQLStore): The SQL store instance.
- Returns:
factory.ProviderFactory[SQLMigration, Config]
: A factory that createsaddAlertmanager
instances.
newAddAlertmanager
- Purpose: Creates a new
addAlertmanager
instance. - Parameters:
_
(context.Context): Context (not used)._
(factory.ProviderSettings): Provider settings (not used)._
(Config): Configuration (not used).store
(sqlstore.SQLStore): The SQL store instance.
- Returns:
(SQLMigration, error)
: A newaddAlertmanager
instance and an error if any.
addAlertmanager.Register
- Purpose: Registers the Up and Down migration functions.
- Parameters:
migrations
(*migrate.Migrations): The migration registry.
- Returns:
error
: An error if registration fails.
addAlertmanager.Up
- Purpose: Executes the Up migration, which adds tables and columns for Alertmanager configuration and state, and populates initial data.
- Parameters:
ctx
(context.Context): The context.db
(*bun.DB): The database connection.
- Returns:
error
: An error if the migration fails.
addAlertmanager.populateOrgIDInChannels
- Purpose: Populates the
org_id
column in thenotification_channels
table with the provided organization ID. - Parameters:
ctx
(context.Context): The context.tx
(bun.Tx): The database transaction.orgID
(string): The organization ID.
- Returns:
error
: An error if the operation fails.
addAlertmanager.populateAlertmanagerConfig
- Purpose: Populates the
alertmanager_config
table with the initial configuration based on existing notification channels and rules. - Parameters:
ctx
(context.Context): The context.tx
(bun.Tx): The database transaction.orgID
(string): The organization ID.
- Returns:
error
: An error if the operation fails.
addAlertmanager.Down
- Purpose: Executes the Down migration (currently empty).
- Parameters:
ctx
(context.Context): The context.db
(*bun.DB): The database connection.
- Returns:
error
: An error if the migration fails.
addAlertmanager.msTeamsChannelToMSTeamsV2Channel
- Purpose: Converts a MS Teams notification channel to a MS Teams V2 notification channel.
- Parameters:
c
(*alertmanagertypes.Channel): The channel to convert.
- Returns:
error
: An error if the conversion fails.
addAlertmanager.msTeamsReceiverToMSTeamsV2Receiver
- Purpose: Converts MS Teams receiver configuration to MS Teams V2 receiver configuration.
- Parameters:
receiver
(alertmanagertypes.Receiver): The receiver to convert.
- Returns:
alertmanagertypes.Receiver
: The converted receiver.
-
Code Examples N/A
-
Clarity and Accuracy The documentation reflects the code accurately.
-
Markdown & MDX Perfection The markdown is correctly formatted.
-
Edge Cases To Avoid Breaking MDX All potential MDX breaking characters have been escaped.
-
Getting Started Relevance Include in Getting Started: NO