-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: fix validation of OpsGenie configuration #2910
config: fix validation of OpsGenie configuration #2910
Conversation
The validation should fail if both `api_key` and `api_key_file` are defined. I think there was a typo in the original PR (prometheus#2728) that enforced `api_url` and `api_key_file` not being defined at the same time. Signed-off-by: Simon Pasquier <[email protected]>
Can you rebase from |
…t-instance-rule` Within grafana/dashboard-linter@9a32e58, the rules have been split into two different rules: `target-job-rule` `target-instance-rule` All of our queries do contain the `job` label but as per the reason, we don't need both in this particular case. Fixes prometheus#2899 Signed-off-by: gotjosh <[email protected]> Signed-off-by: Simon Pasquier <[email protected]>
Thanks! I wanted the change against |
Silly me! I didn't notice that the target branch was different. |
@@ -492,7 +492,7 @@ func (c *OpsGenieConfig) UnmarshalYAML(unmarshal func(interface{}) error) error | |||
return err | |||
} | |||
|
|||
if c.APIURL != nil && len(c.APIKeyFile) > 0 { | |||
if c.APIKey != "" && len(c.APIKeyFile) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if c.APIKey != "" && len(c.APIKeyFile) > 0 { | |
if c.APIURL == nil { | |
return fmt.Errorf("missing URL in config") | |
} | |
if c.APIKey != "" && len(c.APIKeyFile) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to validate the URL as well, DefaultOpsGenieConfig
does not contain a default URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a default OpsGenie URL in the global config.
Line 591 in 23f961e
OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
@@ -590,6 +590,72 @@ func TestOpsgenieTypeMatcher(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestOpsGenieConfiguration(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also include a test here if we decide to include the URL validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The validation should fail if both
api_key
andapi_key_file
aredefined. I think there was a typo in the original PR (#2728) that
enforced
api_url
andapi_key_file
not being defined at the sametime.
cc @jkroepke since you did the initial implementation.