forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
40 lines (34 loc) · 1.11 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package victorops
import (
"net/url"
"github.com/pkg/errors"
)
const DefaultVictorOpsAPIURL = "https://alert.victorops.com/integrations/generic/20131114/alert"
type Config struct {
// Whether to enable Victor Ops integration.
Enabled bool `toml:"enabled" override:"enabled"`
// The Victor Ops API key.
APIKey string `toml:"api-key" override:"api-key,redact"`
// The default Routing Key, can be overridden per alert.
RoutingKey string `toml:"routing-key" override:"routing-key"`
// The Victor Ops API URL, should not need to be changed.
URL string `toml:"url" override:"url"`
// Whether every alert should automatically go to VictorOps.
Global bool `toml:"global" override:"global"`
// JSONData indicates that the VictorOps "data" field should contain JSON and not a string.
JSONData bool `toml:"json-data" override:"json-data"`
}
func NewConfig() Config {
return Config{
URL: DefaultVictorOpsAPIURL,
}
}
func (c Config) Validate() error {
if c.URL == "" {
return errors.New("url cannot be empty")
}
if _, err := url.Parse(c.URL); err != nil {
return errors.Wrapf(err, "invalid URL %q", c.URL)
}
return nil
}