1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Add env var defaults to AzureDevops module

This commit is contained in:
Chris Cummer
2019-09-21 04:13:13 -07:00
parent 2f9025ae2d
commit bb10669b09
3 changed files with 16 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package azuredevops
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
@@ -9,10 +11,11 @@ const defaultTitle = "azuredevops"
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
common *cfg.Common
labelColor string
apiToken string
orgURL string
apiToken string `help:"Your Azure DevOps Access Token."`
orgURL string `help:"Your Azure DevOps organization URL."`
projectName string
maxRows int
}
@@ -20,11 +23,12 @@ type Settings struct {
// 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, ymlConfig, globalConfig),
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
labelColor: ymlConfig.UString("labelColor", "white"),
apiToken: ymlConfig.UString("apiToken", "api token not specified"),
orgURL: ymlConfig.UString("orgURL", "org url not specified"),
projectName: ymlConfig.UString("projectName", "project name not specified"),
apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_AZURE DEVOPS_API_TOKEN")),
orgURL: ymlConfig.UString("orgURL", os.Getenv("WTF_AZURE_DEVOPS_ORG_URL")),
projectName: ymlConfig.UString("projectName", os.Getenv("WTF_AZURE_DEVOPS_PROJECT_NAME")),
maxRows: ymlConfig.UInt("maxRows", 3),
}