-
Notifications
You must be signed in to change notification settings - Fork 1
/
configuration.go
35 lines (31 loc) · 1.2 KB
/
configuration.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
package slack
import (
"flag"
"time"
)
// Vars
var (
ChannelPrefix = flag.String("slack-channel-prefix", "", "the slack channel prefix")
IncomingWebhookURL = flag.String("slack-incoming-webhook-url", "", "the slack incoming webhook url")
RequestTimeout = flag.Duration("slack-request-timeout", 0, "the duration after which a request is considered as having timed out")
RetryMax = flag.Int("slack-retry-max", 0, "the slack max retry")
RetrySleep = flag.Duration("slack-retry-sleep", 0, "the slack max sleep")
)
// Configuration represents the slack configuration
type Configuration struct {
ChannelPrefix string `toml:"channel_prefix"`
IncomingWebhookURL string `toml:"incoming_webhook_url"`
RequestTimeout time.Duration `toml:"request_timeout"`
RetryMax int `toml:"retry_max"`
RetrySleep time.Duration `toml:"retry_sleep"`
}
// FlagConfig generates a Configuration based on flags
func FlagConfig() Configuration {
return Configuration{
ChannelPrefix: *ChannelPrefix,
IncomingWebhookURL: *IncomingWebhookURL,
RequestTimeout: *RequestTimeout,
RetryMax: *RetryMax,
RetrySleep: *RetrySleep,
}
}