|
46 | 46 | errTLSFileNotAllowed = errors.New("setting TLS ca_file, cert_file and key_file is not allowed")
|
47 | 47 | errSlackAPIURLFileNotAllowed = errors.New("setting Slack api_url_file and global slack_api_url_file is not allowed")
|
48 | 48 | errVictorOpsAPIKeyFileNotAllowed = errors.New("setting VictorOps api_key_file is not allowed")
|
| 49 | + errOpsGenieAPIKeyFileNotAllowed = errors.New("setting OpsGenie api_key_file is not allowed") |
49 | 50 | )
|
50 | 51 |
|
51 | 52 | // UserConfig is used to communicate a users alertmanager configs
|
@@ -337,6 +338,11 @@ func validateAlertmanagerConfig(cfg interface{}) error {
|
337 | 338 | return err
|
338 | 339 | }
|
339 | 340 |
|
| 341 | + case reflect.TypeOf(config.OpsGenieConfig{}): |
| 342 | + if err := validateOpsGenieConfig(v.Interface().(config.OpsGenieConfig)); err != nil { |
| 343 | + return err |
| 344 | + } |
| 345 | + |
340 | 346 | case reflect.TypeOf(commoncfg.TLSConfig{}):
|
341 | 347 | if err := validateReceiverTLSConfig(v.Interface().(commoncfg.TLSConfig)); err != nil {
|
342 | 348 | return err
|
@@ -427,12 +433,24 @@ func validateReceiverTLSConfig(cfg commoncfg.TLSConfig) error {
|
427 | 433 | // validateGlobalConfig validates the Global config and returns an error if it contains
|
428 | 434 | // settings now allowed by Cortex.
|
429 | 435 | func validateGlobalConfig(cfg config.GlobalConfig) error {
|
| 436 | + if cfg.OpsGenieAPIKeyFile != "" { |
| 437 | + return errOpsGenieAPIKeyFileNotAllowed |
| 438 | + } |
430 | 439 | if cfg.SlackAPIURLFile != "" {
|
431 | 440 | return errSlackAPIURLFileNotAllowed
|
432 | 441 | }
|
433 | 442 | return nil
|
434 | 443 | }
|
435 | 444 |
|
| 445 | +// validateOpsGenieConfig validates the OpsGenie config and returns an error if it contains |
| 446 | +// settings now allowed by Cortex. |
| 447 | +func validateOpsGenieConfig(cfg config.OpsGenieConfig) error { |
| 448 | + if cfg.APIKeyFile != "" { |
| 449 | + return errOpsGenieAPIKeyFileNotAllowed |
| 450 | + } |
| 451 | + return nil |
| 452 | +} |
| 453 | + |
436 | 454 | // validateSlackConfig validates the Slack config and returns an error if it contains
|
437 | 455 | // settings now allowed by Cortex.
|
438 | 456 | func validateSlackConfig(cfg config.SlackConfig) error {
|
|
0 commit comments