Skip to content

Commit

Permalink
Validate global config too
Browse files Browse the repository at this point in the history
Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com>
  • Loading branch information
friedrichg committed Dec 16, 2022
1 parent 5a62e90 commit bb8e729
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/alertmanager/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ func validateReceiverTLSConfig(cfg commoncfg.TLSConfig) error {
// validateGlobalConfig validates the Global config and returns an error if it contains
// settings now allowed by Cortex.
func validateGlobalConfig(cfg config.GlobalConfig) error {
if cfg.OpsGenieAPIKeyFile != "" {
return errOpsGenieAPIKeyFileNotAllowed
}
if cfg.SlackAPIURLFile != "" {
return errSlackAPIURLFileNotAllowed
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/alertmanager/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,23 @@ alertmanager_config: |
`,
err: errors.Wrap(errOAuth2SecretFileNotAllowed, "error validating Alertmanager config"),
},
{
name: "Should return error if global opsgenie_api_key_file is set",
cfg: `
alertmanager_config: |
global:
opsgenie_api_key_file: /secrets
receivers:
- name: default-receiver
webhook_configs:
- url: http://localhost
route:
receiver: 'default-receiver'
`,
err: errors.Wrap(errOpsGenieAPIKeyFileNotAllowed, "error validating Alertmanager config"),
},
{
name: "Should return error if global slack_api_url_file is set",
cfg: `
Expand Down

0 comments on commit bb8e729

Please sign in to comment.