github.com/wtfutil/wtf@v0.43.0/modules/azuredevops/settings.go (about) 1 package azuredevops 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 ) 9 10 const ( 11 defaultFocus = false 12 defaultTitle = "azuredevops" 13 ) 14 15 // Settings defines the configuration options for this module 16 type Settings struct { 17 *cfg.Common 18 19 apiToken string `help:"Your Azure DevOps Access Token."` 20 labelColor string 21 maxRows int 22 orgURL string `help:"Your Azure DevOps organization URL."` 23 projectName string 24 } 25 26 // NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated 27 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 28 settings := Settings{ 29 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig), 30 31 apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_AZURE_DEVOPS_API_TOKEN")), 32 labelColor: ymlConfig.UString("labelColor", "white"), 33 maxRows: ymlConfig.UInt("maxRows", 3), 34 orgURL: ymlConfig.UString("orgURL", os.Getenv("WTF_AZURE_DEVOPS_ORG_URL")), 35 projectName: ymlConfig.UString("projectName", os.Getenv("WTF_AZURE_DEVOPS_PROJECT_NAME")), 36 } 37 38 cfg.ModuleSecret(name, globalConfig, &settings.apiToken). 39 Service(settings.orgURL).Load() 40 41 return &settings 42 }