@@ -40,12 +40,14 @@ const (
4040)
4141
4242var (
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" )
4951)
5052
5153// UserConfig is used to communicate a users alertmanager configs
@@ -356,6 +358,11 @@ func validateAlertmanagerConfig(cfg interface{}) error {
356358 if err := validateVictorOpsConfig (v .Interface ().(config.VictorOpsConfig )); err != nil {
357359 return err
358360 }
361+
362+ case reflect .TypeOf (config.PagerdutyConfig {}):
363+ if err := validatePagerdutyConfig (v .Interface ().(config.PagerdutyConfig )); err != nil {
364+ return err
365+ }
359366 }
360367
361368 // If the input config is a struct, recursively iterate on all fields.
@@ -430,7 +437,7 @@ func validateReceiverTLSConfig(cfg commoncfg.TLSConfig) error {
430437}
431438
432439// validateGlobalConfig validates the Global config and returns an error if it contains
433- // settings now allowed by Cortex.
440+ // settings not allowed by Cortex.
434441func validateGlobalConfig (cfg config.GlobalConfig ) error {
435442 if cfg .OpsGenieAPIKeyFile != "" {
436443 return errOpsGenieAPIKeyFileNotAllowed
@@ -442,7 +449,7 @@ func validateGlobalConfig(cfg config.GlobalConfig) error {
442449}
443450
444451// validateOpsGenieConfig validates the OpsGenie config and returns an error if it contains
445- // settings now allowed by Cortex.
452+ // settings not allowed by Cortex.
446453func validateOpsGenieConfig (cfg config.OpsGenieConfig ) error {
447454 if cfg .APIKeyFile != "" {
448455 return errOpsGenieAPIKeyFileNotAllowed
@@ -451,7 +458,7 @@ func validateOpsGenieConfig(cfg config.OpsGenieConfig) error {
451458}
452459
453460// validateSlackConfig validates the Slack config and returns an error if it contains
454- // settings now allowed by Cortex.
461+ // settings not allowed by Cortex.
455462func validateSlackConfig (cfg config.SlackConfig ) error {
456463 if cfg .APIURLFile != "" {
457464 return errSlackAPIURLFileNotAllowed
@@ -460,10 +467,24 @@ func validateSlackConfig(cfg config.SlackConfig) error {
460467}
461468
462469// validateVictorOpsConfig validates the VictorOps config and returns an error if it contains
463- // settings now allowed by Cortex.
470+ // settings not allowed by Cortex.
464471func validateVictorOpsConfig (cfg config.VictorOpsConfig ) error {
465472 if cfg .APIKeyFile != "" {
466473 return errVictorOpsAPIKeyFileNotAllowed
467474 }
468475 return nil
469476}
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