Fix config name inconsistency (#1087)

* Rename global config hipchat_url to hipchat_api_url

* Rename opsgenie config 'host' to 'url'
This commit is contained in:
Jose Donizetti 2017-11-11 12:01:21 -02:00 committed by stuart nelson
parent ea9a584e8d
commit 76c15a0ef5
7 changed files with 19 additions and 19 deletions

View File

@ -202,10 +202,10 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
for _, hc := range rcv.HipchatConfigs {
if hc.APIURL == "" {
if c.Global.HipchatURL == "" {
if c.Global.HipchatAPIURL == "" {
return fmt.Errorf("no global Hipchat API URL set")
}
hc.APIURL = c.Global.HipchatURL
hc.APIURL = c.Global.HipchatAPIURL
}
if !strings.HasSuffix(hc.APIURL, "/") {
hc.APIURL += "/"
@ -226,14 +226,14 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
}
for _, ogc := range rcv.OpsGenieConfigs {
if ogc.APIHost == "" {
if c.Global.OpsGenieAPIHost == "" {
if ogc.APIURL == "" {
if c.Global.OpsGenieAPIURL == "" {
return fmt.Errorf("no global OpsGenie URL set")
}
ogc.APIHost = c.Global.OpsGenieAPIHost
ogc.APIURL = c.Global.OpsGenieAPIURL
}
if !strings.HasSuffix(ogc.APIHost, "/") {
ogc.APIHost += "/"
if !strings.HasSuffix(ogc.APIURL, "/") {
ogc.APIURL += "/"
}
}
for _, voc := range rcv.VictorOpsConfigs {
@ -299,8 +299,8 @@ var DefaultGlobalConfig = GlobalConfig{
SMTPRequireTLS: true,
PagerdutyURL: "https://events.pagerduty.com/v2/enqueue",
HipchatURL: "https://api.hipchat.com/",
OpsGenieAPIHost: "https://api.opsgenie.com/",
HipchatAPIURL: "https://api.hipchat.com/",
OpsGenieAPIURL: "https://api.opsgenie.com/",
VictorOpsAPIURL: "https://alert.victorops.com/integrations/generic/20131114/alert/",
}
@ -321,9 +321,9 @@ type GlobalConfig struct {
SMTPRequireTLS bool `yaml:"smtp_require_tls,omitempty" json:"smtp_require_tls,omitempty"`
SlackAPIURL Secret `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"`
PagerdutyURL string `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"`
HipchatURL string `yaml:"hipchat_url,omitempty" json:"hipchat_url,omitempty"`
HipchatAPIURL string `yaml:"hipchat_api_url,omitempty" json:"hipchat_api_url,omitempty"`
HipchatAuthToken Secret `yaml:"hipchat_auth_token,omitempty" json:"hipchat_auth_token,omitempty"`
OpsGenieAPIHost string `yaml:"opsgenie_api_host,omitempty" json:"opsgenie_api_host,omitempty"`
OpsGenieAPIURL string `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"`
VictorOpsAPIURL string `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"`
VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"`

View File

@ -280,11 +280,11 @@ func TestEmptyFieldsAndRegex(t *testing.T) {
SMTPSmarthost: "localhost:25",
SMTPFrom: "alertmanager@example.org",
HipchatAuthToken: "mysecret",
HipchatURL: "https://hipchat.foobar.org/",
HipchatAPIURL: "https://hipchat.foobar.org/",
SlackAPIURL: "mysecret",
SMTPRequireTLS: true,
PagerdutyURL: "https://events.pagerduty.com/v2/enqueue",
OpsGenieAPIHost: "https://api.opsgenie.com/",
OpsGenieAPIURL: "https://api.opsgenie.com/",
VictorOpsAPIURL: "https://alert.victorops.com/integrations/generic/20131114/alert/",
},

View File

@ -300,7 +300,7 @@ type OpsGenieConfig struct {
NotifierConfig `yaml:",inline" json:",inline"`
APIKey Secret `yaml:"api_key,omitempty" json:"api_key,omitempty"`
APIHost string `yaml:"api_host,omitempty" json:"api_host,omitempty"`
APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Source string `yaml:"source,omitempty" json:"source,omitempty"`

View File

@ -5,7 +5,7 @@ global:
smtp_auth_password: ''
smtp_hello: ''
hipchat_auth_token: 'mysecret'
hipchat_url: 'https://hipchat.foobar.org/'
hipchat_api_url: 'https://hipchat.foobar.org/'
slack_api_url: 'mysecret'

View File

@ -8,7 +8,7 @@ global:
# The auth token for Hipchat.
hipchat_auth_token: "mysecret"
# Alternative host for Hipchat.
hipchat_url: 'https://hipchat.foobar.org/'
hipchat_api_url: 'https://hipchat.foobar.org/'
slack_api_url: "mysecret"

View File

@ -7,7 +7,7 @@ global:
# The auth token for Hipchat.
hipchat_auth_token: '1234556789'
# Alternative host for Hipchat.
hipchat_url: 'https://hipchat.foobar.org/'
hipchat_api_url: 'https://hipchat.foobar.org/'
# The directory from which notification templates are read.
templates:

View File

@ -825,7 +825,7 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
)
switch alerts.Status() {
case model.AlertResolved:
apiURL = fmt.Sprintf("%sv2/alerts/%s/close?identifierType=alias", n.conf.APIHost, alias)
apiURL = fmt.Sprintf("%sv2/alerts/%s/close?identifierType=alias", n.conf.APIURL, alias)
msg = &opsGenieCloseMessage{Source: tmpl(n.conf.Source)}
default:
message := tmpl(n.conf.Message)
@ -834,7 +834,7 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
level.Debug(n.logger).Log("msg", "Truncated message to %q due to OpsGenie message limit", "truncated_message", message, "incident", key)
}
apiURL = n.conf.APIHost + "v2/alerts"
apiURL = n.conf.APIURL + "v2/alerts"
msg = &opsGenieCreateMessage{
Alias: alias,
Message: message,