github.com/wtfutil/wtf@v0.43.0/modules/bamboohr/settings.go (about)

     1  package bamboohr
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/olebedev/config"
     7  	"github.com/wtfutil/wtf/cfg"
     8  )
     9  
    10  const (
    11  	defaultFocusable = false
    12  	defaultTitle     = "BambooHR"
    13  )
    14  
    15  type Settings struct {
    16  	*cfg.Common
    17  
    18  	apiKey    string `help:"Your BambooHR API token."`
    19  	subdomain string `help:"Your BambooHR API subdomain name."`
    20  }
    21  
    22  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    23  	settings := Settings{
    24  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    25  
    26  		apiKey:    ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_BAMBOO_HR_TOKEN"))),
    27  		subdomain: ymlConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),
    28  	}
    29  
    30  	cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load()
    31  
    32  	return &settings
    33  }