|
52 | 52 | errPushOverUserKeyFileNotAllowed = errors.New("setting PushOver user_key_file is not allowed")
|
53 | 53 | errPushOverTokenFileNotAllowed = errors.New("setting PushOver token_file is not allowed")
|
54 | 54 | errTelegramBotTokenFileNotAllowed = errors.New("setting Telegram bot_token_file is not allowed")
|
| 55 | + errMSTeamsWebhookUrlFileNotAllowed = errors.New("setting MSTeams webhook_url_file is not allowed") |
| 56 | + errMSTeamsV2WebhookUrlFileNotAllowed = errors.New("setting MSTeamsV2 webhook_url_file is not allowed") |
| 57 | + errRocketChatTokenIdFileNotAllowed = errors.New("setting RocketChat token_id_file is not allowed") |
| 58 | + errRocketChatTokenFileNotAllowed = errors.New("setting RocketChat token_file is not allowed") |
55 | 59 | )
|
56 | 60 |
|
57 | 61 | // UserConfig is used to communicate a users alertmanager configs
|
@@ -383,6 +387,18 @@ func validateAlertmanagerConfig(cfg interface{}) error {
|
383 | 387 | if err := validateTelegramConfig(v.Interface().(config.TelegramConfig)); err != nil {
|
384 | 388 | return err
|
385 | 389 | }
|
| 390 | + case reflect.TypeOf(config.MSTeamsConfig{}): |
| 391 | + if err := validateMSTeamsConfig(v.Interface().(config.MSTeamsConfig)); err != nil { |
| 392 | + return err |
| 393 | + } |
| 394 | + case reflect.TypeOf(config.MSTeamsV2Config{}): |
| 395 | + if err := validateMSTeamsV2Config(v.Interface().(config.MSTeamsV2Config)); err != nil { |
| 396 | + return err |
| 397 | + } |
| 398 | + case reflect.TypeOf(config.RocketchatConfig{}): |
| 399 | + if err := validateRocketChatConfig(v.Interface().(config.RocketchatConfig)); err != nil { |
| 400 | + return err |
| 401 | + } |
386 | 402 | }
|
387 | 403 |
|
388 | 404 | // If the input config is a struct, recursively iterate on all fields.
|
@@ -540,3 +556,35 @@ func validateTelegramConfig(cfg config.TelegramConfig) error {
|
540 | 556 | }
|
541 | 557 | return nil
|
542 | 558 | }
|
| 559 | + |
| 560 | +// validateMSTeamsConfig validates the MSTeams Config and returns an error if it contains |
| 561 | +// settings not allowed by Cortex. |
| 562 | +func validateMSTeamsConfig(cfg config.MSTeamsConfig) error { |
| 563 | + if cfg.WebhookURLFile != "" { |
| 564 | + return errMSTeamsWebhookUrlFileNotAllowed |
| 565 | + } |
| 566 | + return nil |
| 567 | +} |
| 568 | + |
| 569 | +// validateMSTeamsV2Config validates the MSTeamsV2 Config and returns an error if it contains |
| 570 | +// settings not allowed by Cortex. |
| 571 | +func validateMSTeamsV2Config(cfg config.MSTeamsV2Config) error { |
| 572 | + if cfg.WebhookURLFile != "" { |
| 573 | + return errMSTeamsV2WebhookUrlFileNotAllowed |
| 574 | + } |
| 575 | + return nil |
| 576 | +} |
| 577 | + |
| 578 | +// validateRocketChatConfig validates the RocketChat Config and returns an error if it contains |
| 579 | +// settings not allowed by Cortex. |
| 580 | +func validateRocketChatConfig(cfg config.RocketchatConfig) error { |
| 581 | + if cfg.TokenIDFile != "" { |
| 582 | + return errRocketChatTokenIdFileNotAllowed |
| 583 | + } |
| 584 | + |
| 585 | + if cfg.TokenFile != "" { |
| 586 | + return errRocketChatTokenFileNotAllowed |
| 587 | + } |
| 588 | + |
| 589 | + return nil |
| 590 | +} |
0 commit comments