-
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
VictorOps api-key <SECRET> via file feature #2554
Open
gr8Adakron
wants to merge
12
commits into
prometheus:main
Choose a base branch
from
gr8Adakron:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9d41db6
VictorOps api-key <SECRET> via file feature
gr8Adakron 9451c7c
VictorOps api-key <SECRET> via file feature
gr8Adakron cb8bd6b
VictorOps api-key <SECRET> via file feature
gr8Adakron 86de924
VictorOps api-key <SECRET> via file feature
gr8Adakron 04e3b5c
VictorOps api-key <SECRET> via file feature
gr8Adakron ef0b100
VictorOps api-key <SECRET> via file feature
gr8Adakron 2087a94
VictorOps api-key <SECRET> via file feature
gr8Adakron e3610da
VictorOps api-key <SECRET> via file feature
gr8Adakron 53bdf60
Merge branch 'master' into master
gr8Adakron 8a93fde
VictorOps api-key <SECRET> via file feature
gr8Adakron 2846f9b
fixing patch error for pg-api-gateway-vs-host
gr8Adakron 2489bab
VictorOps api-key <SECRET> via file feature
gr8Adakron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,8 +301,12 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { | |
*c.Global = DefaultGlobalConfig() | ||
} | ||
|
||
if c.Global.SlackAPIURL != nil && len(c.Global.SlackAPIURLFile) > 0 { | ||
return fmt.Errorf("at most one of slack_api_url & slack_api_url_file must be configured") | ||
if c.Global.SlackAPIURL != nil { | ||
return fmt.Errorf("at most one of slack_api_url must be configured") | ||
} | ||
|
||
if c.Global.VictorOpsAPIKey != "" && len(c.Global.VictorOpsAPIKeyFile) > 0 { | ||
return fmt.Errorf("at most one of victorops_api_key & victorops_api_key_file must be configured") | ||
} | ||
|
||
names := map[string]struct{}{} | ||
|
@@ -440,11 +444,12 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { | |
if !strings.HasSuffix(voc.APIURL.Path, "/") { | ||
voc.APIURL.Path += "/" | ||
} | ||
if voc.APIKey == "" { | ||
if c.Global.VictorOpsAPIKey == "" { | ||
return fmt.Errorf("no global VictorOps API Key set") | ||
if voc.APIKey == "" && len(voc.APIKeyFile) == 0 { | ||
if c.Global.VictorOpsAPIKey == "" && len(c.Global.VictorOpsAPIKeyFile) == 0 { | ||
return fmt.Errorf("no global VictorOps API Key set either inline or in a file") | ||
} | ||
voc.APIKey = c.Global.VictorOpsAPIKey | ||
voc.APIKeyFile = c.Global.VictorOpsAPIKeyFile | ||
} | ||
} | ||
names[rcv.Name] = struct{}{} | ||
|
@@ -628,24 +633,24 @@ type GlobalConfig struct { | |
|
||
HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"` | ||
|
||
SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` | ||
SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` | ||
SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` | ||
SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` | ||
SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` | ||
SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` | ||
SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` | ||
SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` | ||
SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` | ||
SlackAPIURLFile string `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you are accidentally removing this line about Slack. |
||
PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` | ||
OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` | ||
OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` | ||
WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` | ||
WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` | ||
WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` | ||
VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` | ||
VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` | ||
SMTPFrom string `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"` | ||
SMTPHello string `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"` | ||
SMTPSmarthost HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"` | ||
SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"` | ||
SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` | ||
SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` | ||
SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` | ||
SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` | ||
SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` | ||
PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` | ||
OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` | ||
OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"` | ||
WeChatAPIURL *URL `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"` | ||
WeChatAPISecret Secret `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"` | ||
WeChatAPICorpID string `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"` | ||
VictorOpsAPIURL *URL `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` | ||
VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` | ||
VictorOpsAPIKeyFile string `yaml:"victorops_api_key_file,omitempty" json:"victorops_api_key_file,omitempty"` | ||
} | ||
|
||
// UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
config/testdata/conf.victorops-api-key-both-file-and-inline.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
global: | ||
victorops_api_key: "<SECRET>" | ||
victorops_api_key_file: '/global_file' | ||
|
||
route: | ||
receiver: 'victorops-notifications' | ||
group_by: [alertname, datacenter, app] | ||
|
||
receivers: | ||
- name: 'victorops-notifications' | ||
slack_configs: | ||
- channel: '#alerts1' | ||
text: 'test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
global: | ||
victorops_api_key_file: '/global_file' | ||
|
||
route: | ||
receiver: 'victorops-notifications' | ||
group_by: [alertname, datacenter, app] | ||
|
||
receivers: | ||
- name: 'victorops-notifications' | ||
slack_configs: | ||
# Use global | ||
- channel: '#alerts1' | ||
text: 'test' | ||
# Override global with other file | ||
- channel: '#alerts2' | ||
text: 'test' | ||
victorops_api_key_file: '/override_file' | ||
# Override global with inline URL | ||
- channel: '#alerts3' | ||
text: 'test' | ||
victorops_api_key: '<SECRET>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This code is about Slack and should not change.