mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Support case-insensitive 'apiKey' config keys
'apiKey' is one that people are likely to spell wrong in their configs as 'apikey'. Given that there's no sanity-checking around required config values yet, and a missing API key can cause silent failures in some modules, be liberal in accepting spelling.
This commit is contained in:
parent
17935970fb
commit
fce8b69459
@ -20,7 +20,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_BAMBOO_HR_TOKEN")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_BAMBOO_HR_TOKEN"))),
|
||||||
subdomain: ymlConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),
|
subdomain: ymlConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_CIRCLE_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_CIRCLE_API_KEY"))),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &settings
|
return &settings
|
||||||
|
@ -22,7 +22,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_DATADOG_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_DATADOG_API_KEY"))),
|
||||||
applicationKey: ymlConfig.UString("applicationKey", os.Getenv("WTF_DATADOG_APPLICATION_KEY")),
|
applicationKey: ymlConfig.UString("applicationKey", os.Getenv("WTF_DATADOG_APPLICATION_KEY")),
|
||||||
tags: ymlConfig.UList("monitors.tags"),
|
tags: ymlConfig.UList("monitors.tags"),
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_GITHUB_TOKEN")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITHUB_TOKEN"))),
|
||||||
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),
|
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),
|
||||||
enableStatus: ymlConfig.UBool("enableStatus", false),
|
enableStatus: ymlConfig.UBool("enableStatus", false),
|
||||||
uploadURL: ymlConfig.UString("uploadURL", os.Getenv("WTF_GITHUB_UPLOAD_URL")),
|
uploadURL: ymlConfig.UString("uploadURL", os.Getenv("WTF_GITHUB_UPLOAD_URL")),
|
||||||
|
@ -23,7 +23,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_GITLAB_TOKEN")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITLAB_TOKEN"))),
|
||||||
domain: ymlConfig.UString("domain"),
|
domain: ymlConfig.UString("domain"),
|
||||||
projects: ymlConfig.UMap("projects"),
|
projects: ymlConfig.UMap("projects"),
|
||||||
username: ymlConfig.UString("username"),
|
username: ymlConfig.UString("username"),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package hibp
|
package hibp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
@ -33,7 +34,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := &Settings{
|
settings := &Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", ""),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_HIBP_TOKEN"))),
|
||||||
accounts: utils.ToStrs(ymlConfig.UList("accounts")),
|
accounts: utils.ToStrs(ymlConfig.UList("accounts")),
|
||||||
since: ymlConfig.UString("since", ""),
|
since: ymlConfig.UString("since", ""),
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_JENKINS_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_JENKINS_API_KEY"))),
|
||||||
jobNameRegex: ymlConfig.UString("jobNameRegex", ".*"),
|
jobNameRegex: ymlConfig.UString("jobNameRegex", ".*"),
|
||||||
successBallColor: ymlConfig.UString("successBallColor", "blue"),
|
successBallColor: ymlConfig.UString("successBallColor", "blue"),
|
||||||
url: ymlConfig.UString("url"),
|
url: ymlConfig.UString("url"),
|
||||||
|
@ -34,7 +34,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_JIRA_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_JIRA_API_KEY"))),
|
||||||
domain: ymlConfig.UString("domain"),
|
domain: ymlConfig.UString("domain"),
|
||||||
email: ymlConfig.UString("email"),
|
email: ymlConfig.UString("email"),
|
||||||
jql: ymlConfig.UString("jql"),
|
jql: ymlConfig.UString("jql"),
|
||||||
|
@ -22,7 +22,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_NEW_RELIC_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_NEW_RELIC_API_KEY"))),
|
||||||
applicationID: ymlConfig.UInt("applicationID"),
|
applicationID: ymlConfig.UInt("applicationID"),
|
||||||
deployCount: ymlConfig.UInt("deployCount", 5),
|
deployCount: ymlConfig.UInt("deployCount", 5),
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_OPS_GENIE_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_OPS_GENIE_API_KEY"))),
|
||||||
region: ymlConfig.UString("region", "us"),
|
region: ymlConfig.UString("region", "us"),
|
||||||
displayEmpty: ymlConfig.UBool("displayEmpty", true),
|
displayEmpty: ymlConfig.UBool("displayEmpty", true),
|
||||||
scheduleIdentifierType: ymlConfig.UString("scheduleIdentifierType", "id"),
|
scheduleIdentifierType: ymlConfig.UString("scheduleIdentifierType", "id"),
|
||||||
|
@ -24,7 +24,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_PAGERDUTY_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_PAGERDUTY_API_KEY"))),
|
||||||
escalationFilter: ymlConfig.UList("escalationFilter"),
|
escalationFilter: ymlConfig.UList("escalationFilter"),
|
||||||
scheduleIDs: ymlConfig.UList("scheduleIDs", []interface{}{}),
|
scheduleIDs: ymlConfig.UList("scheduleIDs", []interface{}{}),
|
||||||
showIncidents: ymlConfig.UBool("showIncidents", true),
|
showIncidents: ymlConfig.UBool("showIncidents", true),
|
||||||
|
@ -21,7 +21,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_TODOIST_TOKEN")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_TODOIST_TOKEN"))),
|
||||||
projects: ymlConfig.UList("projects"),
|
projects: ymlConfig.UList("projects"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_TRAVIS_API_TOKEN")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_TRAVIS_API_TOKEN"))),
|
||||||
pro: ymlConfig.UBool("pro", false),
|
pro: ymlConfig.UBool("pro", false),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
accessToken: ymlConfig.UString("accessToken", os.Getenv("WTF_TRELLO_ACCESS_TOKEN")),
|
accessToken: ymlConfig.UString("accessToken", ymlConfig.UString("apikey", os.Getenv("WTF_TRELLO_ACCESS_TOKEN"))),
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_TRELLO_APP_KEY")),
|
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_TRELLO_APP_KEY")),
|
||||||
board: ymlConfig.UString("board"),
|
board: ymlConfig.UString("board"),
|
||||||
username: ymlConfig.UString("username"),
|
username: ymlConfig.UString("username"),
|
||||||
|
@ -23,7 +23,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiID: ymlConfig.UString("apiID", os.Getenv("WTF_VICTOROPS_API_ID")),
|
apiID: ymlConfig.UString("apiID", os.Getenv("WTF_VICTOROPS_API_ID")),
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_VICTOROPS_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_VICTOROPS_API_KEY"))),
|
||||||
team: ymlConfig.UString("team"),
|
team: ymlConfig.UString("team"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_OWM_API_KEY")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_OWM_API_KEY"))),
|
||||||
cityIDs: ymlConfig.UList("cityids"),
|
cityIDs: ymlConfig.UList("cityids"),
|
||||||
language: ymlConfig.UString("language", "EN"),
|
language: ymlConfig.UString("language", "EN"),
|
||||||
tempUnit: ymlConfig.UString("tempUnit", "C"),
|
tempUnit: ymlConfig.UString("tempUnit", "C"),
|
||||||
|
@ -23,7 +23,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
||||||
|
|
||||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("ZENDESK_API")),
|
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("ZENDESK_API"))),
|
||||||
status: ymlConfig.UString("status"),
|
status: ymlConfig.UString("status"),
|
||||||
subdomain: ymlConfig.UString("subdomain", os.Getenv("ZENDESK_SUBDOMAIN")),
|
subdomain: ymlConfig.UString("subdomain", os.Getenv("ZENDESK_SUBDOMAIN")),
|
||||||
username: ymlConfig.UString("username"),
|
username: ymlConfig.UString("username"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user