-
-
Notifications
You must be signed in to change notification settings - Fork 800
/
settings.go
42 lines (33 loc) · 1.24 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
package azuredevops
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const (
defaultFocus = false
defaultTitle = "azuredevops"
)
// Settings defines the configuration options for this module
type Settings struct {
*cfg.Common
apiToken string `help:"Your Azure DevOps Access Token."`
labelColor string
maxRows int
orgURL string `help:"Your Azure DevOps organization URL."`
projectName string
}
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig),
apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_AZURE_DEVOPS_API_TOKEN")),
labelColor: ymlConfig.UString("labelColor", "white"),
maxRows: ymlConfig.UInt("maxRows", 3),
orgURL: ymlConfig.UString("orgURL", os.Getenv("WTF_AZURE_DEVOPS_ORG_URL")),
projectName: ymlConfig.UString("projectName", os.Getenv("WTF_AZURE_DEVOPS_PROJECT_NAME")),
}
cfg.ModuleSecret(name, globalConfig, &settings.apiToken).
Service(settings.orgURL).Load()
return &settings
}