-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.go
58 lines (55 loc) · 1.25 KB
/
settings.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Package settings get configuration from environment variables or/and flags
*/
package settings
import (
"github.com/urfave/cli"
)
var (
Gitlab struct {
Url string
Token string
Refresh int64
Owned bool
}
Port int
)
// NewContext => set configuration from env vars or command parameters
func NewContext() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "gitlab_url, gu",
Value: "https://gitlab.com",
Destination: &Gitlab.Url,
EnvVar: "GITLAB_URL",
Usage: "Gitlab Url",
},
cli.StringFlag{
Name: "gitlab_token, gt",
Value: "xxxxxxxxx-xxx",
Destination: &Gitlab.Token,
EnvVar: "GITLAB_TOKEN",
Usage: "Gitlab Personnal Token",
},
cli.Int64Flag{
Name: "gitlab_refresh, gr",
Value: 30,
Destination: &Gitlab.Refresh,
EnvVar: "GITLAB_REFRESH",
Usage: "Refresh time Gitlab Pipelines status in sec",
},
cli.BoolFlag{
Name: "gitlab_owned, go",
Destination: &Gitlab.Owned,
EnvVar: "GITLAB_OWNED",
Usage: "If you want just yours projects",
},
cli.IntFlag{
Name: "port, p",
Value: 9999,
Destination: &Port,
EnvVar: "PORT",
Usage: "Exporter port",
},
}
}