Skip to content

Commit

Permalink
Revert "feat(3920): add msteamsv2 receiver (prometheus#4024)"
Browse files Browse the repository at this point in the history
This reverts commit e4fb0fb.
  • Loading branch information
mogoll92 committed Oct 23, 2024
1 parent b94cadc commit 61dc82c
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 577 deletions.
4 changes: 2 additions & 2 deletions asset/assets_vfsdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 31 additions & 43 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ func resolveFilepaths(baseDir string, cfg *Config) {
for _, cfg := range receiver.MSTeamsConfigs {
cfg.HTTPConfig.SetDirectory(baseDir)
}
for _, cfg := range receiver.MSTeamsV2Configs {
cfg.HTTPConfig.SetDirectory(baseDir)
}
for _, cfg := range receiver.JiraConfigs {
cfg.HTTPConfig.SetDirectory(baseDir)
}
Expand All @@ -285,7 +282,7 @@ func (mt *MuteTimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) err
return err
}
if mt.Name == "" {
return errors.New("missing name in mute time interval")
return fmt.Errorf("missing name in mute time interval")
}
return nil
}
Expand All @@ -303,7 +300,7 @@ func (ti *TimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}
if ti.Name == "" {
return errors.New("missing name in time interval")
return fmt.Errorf("missing name in time interval")
}
return nil
}
Expand Down Expand Up @@ -349,19 +346,19 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

if c.Global.SlackAPIURL != nil && len(c.Global.SlackAPIURLFile) > 0 {
return errors.New("at most one of slack_api_url & slack_api_url_file must be configured")
return fmt.Errorf("at most one of slack_api_url & slack_api_url_file must be configured")
}

if c.Global.OpsGenieAPIKey != "" && len(c.Global.OpsGenieAPIKeyFile) > 0 {
return errors.New("at most one of opsgenie_api_key & opsgenie_api_key_file must be configured")
return fmt.Errorf("at most one of opsgenie_api_key & opsgenie_api_key_file must be configured")
}

if c.Global.VictorOpsAPIKey != "" && len(c.Global.VictorOpsAPIKeyFile) > 0 {
return errors.New("at most one of victorops_api_key & victorops_api_key_file must be configured")
return fmt.Errorf("at most one of victorops_api_key & victorops_api_key_file must be configured")
}

if len(c.Global.SMTPAuthPassword) > 0 && len(c.Global.SMTPAuthPasswordFile) > 0 {
return errors.New("at most one of smtp_auth_password & smtp_auth_password_file must be configured")
return fmt.Errorf("at most one of smtp_auth_password & smtp_auth_password_file must be configured")
}

names := map[string]struct{}{}
Expand All @@ -381,13 +378,13 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if ec.Smarthost.String() == "" {
if c.Global.SMTPSmarthost.String() == "" {
return errors.New("no global SMTP smarthost set")
return fmt.Errorf("no global SMTP smarthost set")
}
ec.Smarthost = c.Global.SMTPSmarthost
}
if ec.From == "" {
if c.Global.SMTPFrom == "" {
return errors.New("no global SMTP from set")
return fmt.Errorf("no global SMTP from set")
}
ec.From = c.Global.SMTPFrom
}
Expand Down Expand Up @@ -418,7 +415,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if sc.APIURL == nil && len(sc.APIURLFile) == 0 {
if c.Global.SlackAPIURL == nil && len(c.Global.SlackAPIURLFile) == 0 {
return errors.New("no global Slack API URL set either inline or in a file")
return fmt.Errorf("no global Slack API URL set either inline or in a file")
}
sc.APIURL = c.Global.SlackAPIURL
sc.APIURLFile = c.Global.SlackAPIURLFile
Expand All @@ -435,7 +432,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if pdc.URL == nil {
if c.Global.PagerdutyURL == nil {
return errors.New("no global PagerDuty URL set")
return fmt.Errorf("no global PagerDuty URL set")
}
pdc.URL = c.Global.PagerdutyURL
}
Expand All @@ -446,7 +443,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if ogc.APIURL == nil {
if c.Global.OpsGenieAPIURL == nil {
return errors.New("no global OpsGenie URL set")
return fmt.Errorf("no global OpsGenie URL set")
}
ogc.APIURL = c.Global.OpsGenieAPIURL
}
Expand All @@ -455,7 +452,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if ogc.APIKey == "" && len(ogc.APIKeyFile) == 0 {
if c.Global.OpsGenieAPIKey == "" && len(c.Global.OpsGenieAPIKeyFile) == 0 {
return errors.New("no global OpsGenie API Key set either inline or in a file")
return fmt.Errorf("no global OpsGenie API Key set either inline or in a file")
}
ogc.APIKey = c.Global.OpsGenieAPIKey
ogc.APIKeyFile = c.Global.OpsGenieAPIKeyFile
Expand All @@ -468,21 +465,21 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {

if wcc.APIURL == nil {
if c.Global.WeChatAPIURL == nil {
return errors.New("no global Wechat URL set")
return fmt.Errorf("no global Wechat URL set")
}
wcc.APIURL = c.Global.WeChatAPIURL
}

if wcc.APISecret == "" {
if c.Global.WeChatAPISecret == "" {
return errors.New("no global Wechat ApiSecret set")
return fmt.Errorf("no global Wechat ApiSecret set")
}
wcc.APISecret = c.Global.WeChatAPISecret
}

if wcc.CorpID == "" {
if c.Global.WeChatAPICorpID == "" {
return errors.New("no global Wechat CorpID set")
return fmt.Errorf("no global Wechat CorpID set")
}
wcc.CorpID = c.Global.WeChatAPICorpID
}
Expand All @@ -497,7 +494,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if voc.APIURL == nil {
if c.Global.VictorOpsAPIURL == nil {
return errors.New("no global VictorOps URL set")
return fmt.Errorf("no global VictorOps URL set")
}
voc.APIURL = c.Global.VictorOpsAPIURL
}
Expand All @@ -506,7 +503,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if voc.APIKey == "" && len(voc.APIKeyFile) == 0 {
if c.Global.VictorOpsAPIKey == "" && len(c.Global.VictorOpsAPIKeyFile) == 0 {
return errors.New("no global VictorOps API Key set")
return fmt.Errorf("no global VictorOps API Key set")
}
voc.APIKey = c.Global.VictorOpsAPIKey
voc.APIKeyFile = c.Global.VictorOpsAPIKeyFile
Expand All @@ -531,7 +528,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
discord.HTTPConfig = c.Global.HTTPConfig
}
if discord.WebhookURL == nil && len(discord.WebhookURLFile) == 0 {
return errors.New("no discord webhook URL or URLFile provided")
return fmt.Errorf("no discord webhook URL or URLFile provided")
}
}
for _, webex := range rcv.WebexConfigs {
Expand All @@ -540,7 +537,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if webex.APIURL == nil {
if c.Global.WebexAPIURL == nil {
return errors.New("no global Webex URL set")
return fmt.Errorf("no global Webex URL set")
}

webex.APIURL = c.Global.WebexAPIURL
Expand All @@ -551,15 +548,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
msteams.HTTPConfig = c.Global.HTTPConfig
}
if msteams.WebhookURL == nil && len(msteams.WebhookURLFile) == 0 {
return errors.New("no msteams webhook URL or URLFile provided")
}
}
for _, msteamsv2 := range rcv.MSTeamsV2Configs {
if msteamsv2.HTTPConfig == nil {
msteamsv2.HTTPConfig = c.Global.HTTPConfig
}
if msteamsv2.WebhookURL == nil && len(msteamsv2.WebhookURLFile) == 0 {
return errors.New("no msteamsv2 webhook URL or URLFile provided")
return fmt.Errorf("no msteams webhook URL or URLFile provided")
}
}
for _, jira := range rcv.JiraConfigs {
Expand All @@ -568,7 +557,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
if jira.APIURL == nil {
if c.Global.JiraAPIURL == nil {
return errors.New("no global Jira Cloud URL set")
return fmt.Errorf("no global Jira Cloud URL set")
}
jira.APIURL = c.Global.JiraAPIURL
}
Expand All @@ -580,20 +569,20 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
// The root route must not have any matchers as it is the fallback node
// for all alerts.
if c.Route == nil {
return errors.New("no routes provided")
return fmt.Errorf("no routes provided")
}
if len(c.Route.Receiver) == 0 {
return errors.New("root route must specify a default receiver")
return fmt.Errorf("root route must specify a default receiver")
}
if len(c.Route.Match) > 0 || len(c.Route.MatchRE) > 0 || len(c.Route.Matchers) > 0 {
return errors.New("root route must not have any matchers")
return fmt.Errorf("root route must not have any matchers")
}
if len(c.Route.MuteTimeIntervals) > 0 {
return errors.New("root route must not have any mute time intervals")
return fmt.Errorf("root route must not have any mute time intervals")
}

if len(c.Route.ActiveTimeIntervals) > 0 {
return errors.New("root route must not have any active time intervals")
return fmt.Errorf("root route must not have any active time intervals")
}

// Validate that all receivers used in the routing tree are defined.
Expand Down Expand Up @@ -696,7 +685,7 @@ func parseURL(s string) (*URL, error) {
return nil, fmt.Errorf("unsupported scheme %q for URL", u.Scheme)
}
if u.Host == "" {
return nil, errors.New("missing host for URL")
return nil, fmt.Errorf("missing host for URL")
}
return &URL{u}, nil
}
Expand Down Expand Up @@ -859,7 +848,7 @@ func (r *Route) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

if len(r.GroupBy) > 0 && r.GroupByAll {
return errors.New("cannot have wildcard group_by (`...`) and other other labels at the same time")
return fmt.Errorf("cannot have wildcard group_by (`...`) and other other labels at the same time")
}

groupBy := map[model.LabelName]struct{}{}
Expand All @@ -872,10 +861,10 @@ func (r *Route) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

if r.GroupInterval != nil && time.Duration(*r.GroupInterval) == time.Duration(0) {
return errors.New("group_interval cannot be zero")
return fmt.Errorf("group_interval cannot be zero")
}
if r.RepeatInterval != nil && time.Duration(*r.RepeatInterval) == time.Duration(0) {
return errors.New("repeat_interval cannot be zero")
return fmt.Errorf("repeat_interval cannot be zero")
}

return nil
Expand Down Expand Up @@ -946,7 +935,6 @@ type Receiver struct {
TelegramConfigs []*TelegramConfig `yaml:"telegram_configs,omitempty" json:"telegram_configs,omitempty"`
WebexConfigs []*WebexConfig `yaml:"webex_configs,omitempty" json:"webex_configs,omitempty"`
MSTeamsConfigs []*MSTeamsConfig `yaml:"msteams_configs,omitempty" json:"msteams_configs,omitempty"`
MSTeamsV2Configs []*MSTeamsV2Config `yaml:"msteamsv2_configs,omitempty" json:"msteamsv2_configs,omitempty"`
JiraConfigs []*JiraConfig `yaml:"jira_configs,omitempty" json:"jira_configs,omitempty"`
}

Expand All @@ -957,7 +945,7 @@ func (c *Receiver) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}
if c.Name == "" {
return errors.New("missing name in receiver")
return fmt.Errorf("missing name in receiver")
}
return nil
}
Expand Down
Loading

0 comments on commit 61dc82c

Please sign in to comment.