@@ -40,12 +40,14 @@ const (
40
40
)
41
41
42
42
var (
43
- errPasswordFileNotAllowed = errors .New ("setting password_file, bearer_token_file and credentials_file is not allowed" )
44
- errOAuth2SecretFileNotAllowed = errors .New ("setting OAuth2 client_secret_file is not allowed" )
45
- errTLSFileNotAllowed = errors .New ("setting TLS ca_file, cert_file and key_file is not allowed" )
46
- errSlackAPIURLFileNotAllowed = errors .New ("setting Slack api_url_file and global slack_api_url_file is not allowed" )
47
- errVictorOpsAPIKeyFileNotAllowed = errors .New ("setting VictorOps api_key_file is not allowed" )
48
- errOpsGenieAPIKeyFileNotAllowed = errors .New ("setting OpsGenie api_key_file is not allowed" )
43
+ errPasswordFileNotAllowed = errors .New ("setting password_file, bearer_token_file and credentials_file is not allowed" )
44
+ errOAuth2SecretFileNotAllowed = errors .New ("setting OAuth2 client_secret_file is not allowed" )
45
+ errTLSFileNotAllowed = errors .New ("setting TLS ca_file, cert_file and key_file is not allowed" )
46
+ errSlackAPIURLFileNotAllowed = errors .New ("setting Slack api_url_file and global slack_api_url_file is not allowed" )
47
+ errVictorOpsAPIKeyFileNotAllowed = errors .New ("setting VictorOps api_key_file is not allowed" )
48
+ errOpsGenieAPIKeyFileNotAllowed = errors .New ("setting OpsGenie api_key_file is not allowed" )
49
+ errPagerDutyRoutingKeyFileNotAllowed = errors .New ("setting PagerDuty routing_key_file is not allowed" )
50
+ errPagerDutyServiceKeyFileNotAllowed = errors .New ("setting PagerDuty service_key_file is not allowed" )
49
51
)
50
52
51
53
// UserConfig is used to communicate a users alertmanager configs
@@ -356,6 +358,11 @@ func validateAlertmanagerConfig(cfg interface{}) error {
356
358
if err := validateVictorOpsConfig (v .Interface ().(config.VictorOpsConfig )); err != nil {
357
359
return err
358
360
}
361
+
362
+ case reflect .TypeOf (config.PagerdutyConfig {}):
363
+ if err := validatePagerdutyConfig (v .Interface ().(config.PagerdutyConfig )); err != nil {
364
+ return err
365
+ }
359
366
}
360
367
361
368
// If the input config is a struct, recursively iterate on all fields.
@@ -430,7 +437,7 @@ func validateReceiverTLSConfig(cfg commoncfg.TLSConfig) error {
430
437
}
431
438
432
439
// validateGlobalConfig validates the Global config and returns an error if it contains
433
- // settings now allowed by Cortex.
440
+ // settings not allowed by Cortex.
434
441
func validateGlobalConfig (cfg config.GlobalConfig ) error {
435
442
if cfg .OpsGenieAPIKeyFile != "" {
436
443
return errOpsGenieAPIKeyFileNotAllowed
@@ -442,7 +449,7 @@ func validateGlobalConfig(cfg config.GlobalConfig) error {
442
449
}
443
450
444
451
// validateOpsGenieConfig validates the OpsGenie config and returns an error if it contains
445
- // settings now allowed by Cortex.
452
+ // settings not allowed by Cortex.
446
453
func validateOpsGenieConfig (cfg config.OpsGenieConfig ) error {
447
454
if cfg .APIKeyFile != "" {
448
455
return errOpsGenieAPIKeyFileNotAllowed
@@ -451,7 +458,7 @@ func validateOpsGenieConfig(cfg config.OpsGenieConfig) error {
451
458
}
452
459
453
460
// validateSlackConfig validates the Slack config and returns an error if it contains
454
- // settings now allowed by Cortex.
461
+ // settings not allowed by Cortex.
455
462
func validateSlackConfig (cfg config.SlackConfig ) error {
456
463
if cfg .APIURLFile != "" {
457
464
return errSlackAPIURLFileNotAllowed
@@ -460,10 +467,24 @@ func validateSlackConfig(cfg config.SlackConfig) error {
460
467
}
461
468
462
469
// validateVictorOpsConfig validates the VictorOps config and returns an error if it contains
463
- // settings now allowed by Cortex.
470
+ // settings not allowed by Cortex.
464
471
func validateVictorOpsConfig (cfg config.VictorOpsConfig ) error {
465
472
if cfg .APIKeyFile != "" {
466
473
return errVictorOpsAPIKeyFileNotAllowed
467
474
}
468
475
return nil
469
476
}
477
+
478
+ // validatePagerdutyConfig validates the pager duty config and returns an error if it contains
479
+ // settings not allowed by Cortex.
480
+ func validatePagerdutyConfig (cfg config.PagerdutyConfig ) error {
481
+ if cfg .RoutingKeyFile != "" {
482
+ return errPagerDutyRoutingKeyFileNotAllowed
483
+ }
484
+
485
+ if cfg .ServiceKeyFile != "" {
486
+ return errPagerDutyServiceKeyFileNotAllowed
487
+ }
488
+
489
+ return nil
490
+ }
0 commit comments