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