mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-28 02:43:10 +01:00
7de5a1fe48
* feat: implement Gitea alerting provider integration - Add TypeGitea for the gitea alerting provider - Introduce a new file for the gitea alerting provider implementation - Implement the AlertProvider struct with necessary fields for gitea integration - Add validation logic for the AlertProvider configuration - Create tests for the AlertProvider's validation and sending functionality - Update go.mod to include the gitea SDK as a dependency - Modify the alerting configuration validation to recognize TypeGitea Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * chore: integrate Gitea alerting provider configuration - Add Gitea alerting provider import to the configuration file - Update the comment for the RepositoryURL field to reflect Gitea instead of GitHub Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * feat: add Assignees support to AlertProvider functionality - Add a field for Assignees to the AlertProvider struct - Update the Send function to include Assignees in the alert payload Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * feat: implement Gitea alerting configuration and documentation - Add a new image asset for Gitea alerts - Update the README to include configuration details for Gitea alerts - Introduce parameters for Gitea alerting, including repository URL and personal access token - Document the behavior of the Gitea alerting provider regarding issue creation and resolution - Include an example YAML configuration for Gitea alerts Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * Update README.md Co-authored-by: TwiN <twin@linux.com> * Update README.md Co-authored-by: TwiN <twin@linux.com> * Update README.md Co-authored-by: TwiN <twin@linux.com> * feat: refactor AlertProvider for improved client configuration - Add import for the Gatus client library - Remove the SkipVerify field from the AlertProvider struct - Introduce ClientConfig field in the AlertProvider struct for client configuration - Update validation logic to check for ClientConfig instead of SkipVerify Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * Update README.md Co-authored-by: TwiN <twin@linux.com> * chore: update configuration for Gitea integration - Change references from GitHub to Gitea in the configuration section - Update alerting provider descriptions to reflect the correct platform - Swap the order of GitHub and Gitea configurations - Replace Gitea alert image with GitHub alert image - Adjust the type field from gitea to github in the relevant sections Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * fix: ensure ClientConfig is validated and defaults set - Add a check for nil ClientConfig in the IsValid function - Set ClientConfig to a default configuration if it is nil Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-authored-by: TwiN <twin@linux.com>
85 lines
3.4 KiB
Go
85 lines
3.4 KiB
Go
package provider
|
|
|
|
import (
|
|
"github.com/TwiN/gatus/v5/alerting/alert"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/awsses"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/custom"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/discord"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/email"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/gitea"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/github"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/gitlab"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/googlechat"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/jetbrainsspace"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/matrix"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/mattermost"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/messagebird"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/ntfy"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/opsgenie"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/pagerduty"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/pushover"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/slack"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/teams"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/telegram"
|
|
"github.com/TwiN/gatus/v5/alerting/provider/twilio"
|
|
"github.com/TwiN/gatus/v5/config/endpoint"
|
|
)
|
|
|
|
// AlertProvider is the interface that each provider should implement
|
|
type AlertProvider interface {
|
|
// IsValid returns whether the provider's configuration is valid
|
|
IsValid() bool
|
|
|
|
// GetDefaultAlert returns the provider's default alert configuration
|
|
GetDefaultAlert() *alert.Alert
|
|
|
|
// Send an alert using the provider
|
|
Send(ep *endpoint.Endpoint, alert *alert.Alert, result *endpoint.Result, resolved bool) error
|
|
}
|
|
|
|
// ParseWithDefaultAlert parses an Endpoint alert by using the provider's default alert as a baseline
|
|
func ParseWithDefaultAlert(providerDefaultAlert, endpointAlert *alert.Alert) {
|
|
if providerDefaultAlert == nil || endpointAlert == nil {
|
|
return
|
|
}
|
|
if endpointAlert.Enabled == nil {
|
|
endpointAlert.Enabled = providerDefaultAlert.Enabled
|
|
}
|
|
if endpointAlert.SendOnResolved == nil {
|
|
endpointAlert.SendOnResolved = providerDefaultAlert.SendOnResolved
|
|
}
|
|
if endpointAlert.Description == nil {
|
|
endpointAlert.Description = providerDefaultAlert.Description
|
|
}
|
|
if endpointAlert.FailureThreshold == 0 {
|
|
endpointAlert.FailureThreshold = providerDefaultAlert.FailureThreshold
|
|
}
|
|
if endpointAlert.SuccessThreshold == 0 {
|
|
endpointAlert.SuccessThreshold = providerDefaultAlert.SuccessThreshold
|
|
}
|
|
}
|
|
|
|
var (
|
|
// Validate interface implementation on compile
|
|
_ AlertProvider = (*awsses.AlertProvider)(nil)
|
|
_ AlertProvider = (*custom.AlertProvider)(nil)
|
|
_ AlertProvider = (*discord.AlertProvider)(nil)
|
|
_ AlertProvider = (*email.AlertProvider)(nil)
|
|
_ AlertProvider = (*github.AlertProvider)(nil)
|
|
_ AlertProvider = (*gitlab.AlertProvider)(nil)
|
|
_ AlertProvider = (*gitea.AlertProvider)(nil)
|
|
_ AlertProvider = (*googlechat.AlertProvider)(nil)
|
|
_ AlertProvider = (*jetbrainsspace.AlertProvider)(nil)
|
|
_ AlertProvider = (*matrix.AlertProvider)(nil)
|
|
_ AlertProvider = (*mattermost.AlertProvider)(nil)
|
|
_ AlertProvider = (*messagebird.AlertProvider)(nil)
|
|
_ AlertProvider = (*ntfy.AlertProvider)(nil)
|
|
_ AlertProvider = (*opsgenie.AlertProvider)(nil)
|
|
_ AlertProvider = (*pagerduty.AlertProvider)(nil)
|
|
_ AlertProvider = (*pushover.AlertProvider)(nil)
|
|
_ AlertProvider = (*slack.AlertProvider)(nil)
|
|
_ AlertProvider = (*teams.AlertProvider)(nil)
|
|
_ AlertProvider = (*telegram.AlertProvider)(nil)
|
|
_ AlertProvider = (*twilio.AlertProvider)(nil)
|
|
)
|