github.com/wtfutil/wtf@v0.43.0/modules/jenkins/settings.go (about) 1 package jenkins 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 ) 9 10 const ( 11 defaultFocusable = true 12 defaultTitle = "Jenkins" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 apiKey string `help:"Your Jenkins API key."` 19 jobNameRegex string `help:"A regex that filters the jobs shown in the widget." optional:"true"` 20 successBallColor string `help:"Changes the default color of successful Jenkins jobs to the color of your choosing." values:"blue, green, purple, yellow, etc." optional:"true"` 21 url string `help:"The url to your Jenkins project or view."` 22 user string `help:"Your Jenkins username."` 23 verifyServerCertificate bool `help:"Determines whether or not the server’s certificate chain and host name are verified." values:"true or false" optional:"true"` 24 } 25 26 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 27 28 settings := Settings{ 29 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 30 31 apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_JENKINS_API_KEY"))), 32 jobNameRegex: ymlConfig.UString("jobNameRegex", ".*"), 33 successBallColor: ymlConfig.UString("successBallColor", "blue"), 34 url: ymlConfig.UString("url"), 35 user: ymlConfig.UString("user"), 36 verifyServerCertificate: ymlConfig.UBool("verifyServerCertificate", true), 37 } 38 39 cfg.ModuleSecret(name, globalConfig, &settings.apiKey). 40 Service(settings.url).Load() 41 42 return &settings 43 }