github.com/wtfutil/wtf@v0.43.0/modules/cds/status/settings.go (about) 1 package cdsstatus 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 = "CDS Status" 13 ) 14 15 // Settings defines the configuration properties for this module 16 type Settings struct { 17 *cfg.Common 18 19 token string `help:"Your CDS API token."` 20 apiURL string `help:"Your CDS API URL."` 21 uiURL string 22 } 23 24 // NewSettingsFromYAML creates a new settings instance from a YAML config block 25 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 26 settings := Settings{ 27 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 28 29 token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))), 30 apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")), 31 } 32 33 settings.SetDocumentationPath("cds/status") 34 35 return &settings 36 }