Skip to content
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

Conversation

simonpasquier
Copy link
Member

The validation should fail if both api_key and api_key_file are
defined. I think there was a typo in the original PR (#2728) that
enforced api_url and api_key_file not being defined at the same
time.

cc @jkroepke since you did the initial implementation.

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 <spasquie@redhat.com>
@gotjosh
Copy link
Member

gotjosh commented May 4, 2022

Can you rebase from main? I think this the failure relates to #2899 which was fixed a few days ago.

…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 <josue.abreu@gmail.com>

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier
Copy link
Member Author

Thanks! I wanted the change against release-0.24 to cut v0.24.1 right after since api_key_file was added in v0.24.0 :)
I've cherry-picked 35bf59f instead...

@gotjosh
Copy link
Member

gotjosh commented May 5, 2022

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {

Copy link
Member

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.

Copy link
Member Author

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.

OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"),

Copy link
Member

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) {
Copy link
Member

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?

Copy link
Member

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonpasquier simonpasquier merged commit 14b01e6 into prometheus:release-0.24 May 5, 2022
@simonpasquier simonpasquier deleted the fix-opsgenie-configuration-validation branch May 5, 2022 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants