Skip to content

Commit

Permalink
Remove HipChat
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
  • Loading branch information
roidelapluie committed Jun 5, 2020
1 parent 12da9d6 commit ed3dfac
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 304 deletions.
6 changes: 3 additions & 3 deletions api/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,15 @@ func TestSilenceFiltering(t *testing.T) {
}

func TestReceiversMatchFilter(t *testing.T) {
receivers := []string{"pagerduty", "slack", "hipchat"}
receivers := []string{"pagerduty", "slack", "pushover"}

filter, err := regexp.Compile(fmt.Sprintf("^(?:%s)$", "hip.*"))
filter, err := regexp.Compile(fmt.Sprintf("^(?:%s)$", "push.*"))
if err != nil {
t.Errorf("Unexpected error %v", err)
}
require.True(t, receiversMatchFilter(receivers, filter))

filter, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", "hip"))
filter, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", "push"))
if err != nil {
t.Errorf("Unexpected error %v", err)
}
Expand Down
4 changes: 0 additions & 4 deletions cmd/alertmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
"github.com/prometheus/alertmanager/nflog"
"github.com/prometheus/alertmanager/notify"
"github.com/prometheus/alertmanager/notify/email"
"github.com/prometheus/alertmanager/notify/hipchat"
"github.com/prometheus/alertmanager/notify/opsgenie"
"github.com/prometheus/alertmanager/notify/pagerduty"
"github.com/prometheus/alertmanager/notify/pushover"
Expand Down Expand Up @@ -157,9 +156,6 @@ func buildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, log
for i, c := range nc.SlackConfigs {
add("slack", i, c, func(l log.Logger) (notify.Notifier, error) { return slack.New(c, tmpl, l) })
}
for i, c := range nc.HipchatConfigs {
add("hipchat", i, c, func(l log.Logger) (notify.Notifier, error) { return hipchat.New(c, tmpl, l) })
}
for i, c := range nc.VictorOpsConfigs {
add("victorops", i, c, func(l log.Logger) (notify.Notifier, error) { return victorops.New(c, tmpl, l) })
}
Expand Down
24 changes: 0 additions & 24 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
sc.APIURL = c.Global.SlackAPIURL
}
}
for _, hc := range rcv.HipchatConfigs {
if hc.HTTPConfig == nil {
hc.HTTPConfig = c.Global.HTTPConfig
}
if hc.APIURL == nil {
if c.Global.HipchatAPIURL == nil {
return fmt.Errorf("no global Hipchat API URL set")
}
hc.APIURL = c.Global.HipchatAPIURL
}
if !strings.HasSuffix(hc.APIURL.Path, "/") {
hc.APIURL.Path += "/"
}
if hc.AuthToken == "" {
if c.Global.HipchatAuthToken == "" {
return fmt.Errorf("no global Hipchat Auth Token set")
}
hc.AuthToken = c.Global.HipchatAuthToken
}
}
for _, poc := range rcv.PushoverConfigs {
if poc.HTTPConfig == nil {
poc.HTTPConfig = c.Global.HTTPConfig
Expand Down Expand Up @@ -459,7 +439,6 @@ func DefaultGlobalConfig() GlobalConfig {
SMTPHello: "localhost",
SMTPRequireTLS: true,
PagerdutyURL: mustParseURL("https://events.pagerduty.com/v2/enqueue"),
HipchatAPIURL: mustParseURL("https://api.hipchat.com/"),
OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"),
WeChatAPIURL: mustParseURL("https://qyapi.weixin.qq.com/cgi-bin/"),
VictorOpsAPIURL: mustParseURL("https://alert.victorops.com/integrations/generic/20131114/alert/"),
Expand Down Expand Up @@ -574,8 +553,6 @@ type GlobalConfig struct {
SMTPRequireTLS bool `yaml:"smtp_require_tls,omitempty" 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"`
HipchatAPIURL *URL `yaml:"hipchat_api_url,omitempty" json:"hipchat_api_url,omitempty"`
HipchatAuthToken Secret `yaml:"hipchat_auth_token,omitempty" json:"hipchat_auth_token,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"`
Expand Down Expand Up @@ -708,7 +685,6 @@ type Receiver struct {

EmailConfigs []*EmailConfig `yaml:"email_configs,omitempty" json:"email_configs,omitempty"`
PagerdutyConfigs []*PagerdutyConfig `yaml:"pagerduty_configs,omitempty" json:"pagerduty_configs,omitempty"`
HipchatConfigs []*HipchatConfig `yaml:"hipchat_configs,omitempty" json:"hipchat_configs,omitempty"`
SlackConfigs []*SlackConfig `yaml:"slack_configs,omitempty" json:"slack_configs,omitempty"`
WebhookConfigs []*WebhookConfig `yaml:"webhook_configs,omitempty" json:"webhook_configs,omitempty"`
OpsGenieConfigs []*OpsGenieConfig `yaml:"opsgenie_configs,omitempty" json:"opsgenie_configs,omitempty"`
Expand Down
24 changes: 11 additions & 13 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func TestHideConfigSecrets(t *testing.T) {

// String method must not reveal authentication credentials.
s := c.String()
if strings.Count(s, "<secret>") != 15 || strings.Contains(s, "mysecret") {
if strings.Count(s, "<secret>") != 13 || strings.Contains(s, "mysecret") {
t.Fatal("config's String method reveals authentication credentials.")
}
}
Expand Down Expand Up @@ -548,18 +548,16 @@ func TestEmptyFieldsAndRegex(t *testing.T) {
var expectedConf = Config{

Global: &GlobalConfig{
HTTPConfig: &commoncfg.HTTPClientConfig{},
ResolveTimeout: model.Duration(5 * time.Minute),
SMTPSmarthost: HostPort{Host: "localhost", Port: "25"},
SMTPFrom: "alertmanager@example.org",
HipchatAuthToken: "mysecret",
HipchatAPIURL: mustParseURL("https://hipchat.foobar.org/"),
SlackAPIURL: (*SecretURL)(mustParseURL("http://slack.example.com/")),
SMTPRequireTLS: true,
PagerdutyURL: mustParseURL("https://events.pagerduty.com/v2/enqueue"),
OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"),
WeChatAPIURL: mustParseURL("https://qyapi.weixin.qq.com/cgi-bin/"),
VictorOpsAPIURL: mustParseURL("https://alert.victorops.com/integrations/generic/20131114/alert/"),
HTTPConfig: &commoncfg.HTTPClientConfig{},
ResolveTimeout: model.Duration(5 * time.Minute),
SMTPSmarthost: HostPort{Host: "localhost", Port: "25"},
SMTPFrom: "alertmanager@example.org",
SlackAPIURL: (*SecretURL)(mustParseURL("http://slack.example.com/")),
SMTPRequireTLS: true,
PagerdutyURL: mustParseURL("https://events.pagerduty.com/v2/enqueue"),
OpsGenieAPIURL: mustParseURL("https://api.opsgenie.com/"),
WeChatAPIURL: mustParseURL("https://qyapi.weixin.qq.com/cgi-bin/"),
VictorOpsAPIURL: mustParseURL("https://alert.victorops.com/integrations/generic/20131114/alert/"),
},

Templates: []string{
Expand Down
41 changes: 0 additions & 41 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,6 @@ var (
Footer: `{{ template "slack.default.footer" . }}`,
}

// DefaultHipchatConfig defines default values for Hipchat configurations.
DefaultHipchatConfig = HipchatConfig{
NotifierConfig: NotifierConfig{
VSendResolved: false,
},
Color: `{{ if eq .Status "firing" }}red{{ else }}green{{ end }}`,
From: `{{ template "hipchat.default.from" . }}`,
Notify: false,
Message: `{{ template "hipchat.default.message" . }}`,
MessageFormat: `text`,
}

// DefaultOpsGenieConfig defines default values for OpsGenie configurations.
DefaultOpsGenieConfig = OpsGenieConfig{
NotifierConfig: NotifierConfig{
Expand Down Expand Up @@ -372,35 +360,6 @@ func (c *SlackConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return unmarshal((*plain)(c))
}

// HipchatConfig configures notifications via Hipchat.
type HipchatConfig struct {
NotifierConfig `yaml:",inline" json:",inline"`

HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`

APIURL *URL `yaml:"api_url,omitempty" json:"api_url,omitempty"`
AuthToken Secret `yaml:"auth_token,omitempty" json:"auth_token,omitempty"`
RoomID string `yaml:"room_id,omitempty" json:"room_id,omitempty"`
From string `yaml:"from,omitempty" json:"from,omitempty"`
Notify bool `yaml:"notify,omitempty" json:"notify,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
MessageFormat string `yaml:"message_format,omitempty" json:"message_format,omitempty"`
Color string `yaml:"color,omitempty" json:"color,omitempty"`
}

// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (c *HipchatConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultHipchatConfig
type plain HipchatConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if c.RoomID == "" {
return fmt.Errorf("missing room id in Hipchat config")
}
return nil
}

// WebhookConfig configures notifications via a generic webhook.
type WebhookConfig struct {
NotifierConfig `yaml:",inline" json:",inline"`
Expand Down
17 changes: 0 additions & 17 deletions config/notifiers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,6 @@ details:
}
}

func TestHipchatRoomIDIsPresent(t *testing.T) {
in := `
room_id: ''
`
var cfg HipchatConfig
err := yaml.UnmarshalStrict([]byte(in), &cfg)

expected := "missing room id in Hipchat config"

if err == nil {
t.Fatalf("no error returned, expected:\n%v", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%v\ngot:\n%v", expected, err.Error())
}
}

func TestWebhookURLIsPresent(t *testing.T) {
in := `{}`
var cfg WebhookConfig
Expand Down
2 changes: 0 additions & 2 deletions config/testdata/conf.empty-fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ global:
smtp_auth_username: ''
smtp_auth_password: ''
smtp_hello: ''
hipchat_auth_token: 'mysecret'
hipchat_api_url: 'https://hipchat.foobar.org/'
slack_api_url: 'https://slack.com/webhook'


Expand Down
10 changes: 0 additions & 10 deletions config/testdata/conf.good.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ global:
smtp_auth_username: 'alertmanager'
smtp_auth_password: "multiline\nmysecret"
smtp_hello: "host.example.org"
# The auth token for Hipchat.
hipchat_auth_token: "mysecret"
# Alternative host for Hipchat.
hipchat_api_url: 'https://hipchat.foobar.org/'
slack_api_url: "http://mysecret.example.com/"
http_config:
proxy_url: 'http://127.0.0.1:1025'
Expand Down Expand Up @@ -123,12 +119,6 @@ receivers:
- name: 'team-DB-pager'
pagerduty_configs:
- routing_key: "mysecret"
- name: 'team-X-hipchat'
hipchat_configs:
- auth_token: "mysecret"
room_id: 85
message_format: html
notify: true
- name: victorOps-receiver
victorops_configs:
- api_key: mysecret
Expand Down
11 changes: 0 additions & 11 deletions doc/examples/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ global:
smtp_from: 'alertmanager@example.org'
smtp_auth_username: 'alertmanager'
smtp_auth_password: 'password'
# The auth token for Hipchat.
hipchat_auth_token: '1234556789'
# Alternative host for Hipchat.
hipchat_api_url: 'https://hipchat.foobar.org/'

# The directory from which notification templates are read.
templates:
Expand Down Expand Up @@ -126,10 +122,3 @@ receivers:
- name: 'team-DB-pager'
pagerduty_configs:
- service_key: <team-DB-key>

- name: 'team-X-hipchat'
hipchat_configs:
- auth_token: <auth_token>
room_id: 85
message_format: html
notify: true
112 changes: 0 additions & 112 deletions notify/hipchat/hipchat.go

This file was deleted.

Loading

0 comments on commit ed3dfac

Please sign in to comment.