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

     1  package victorops
     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     = "VictorOps"
    13  )
    14  
    15  type Settings struct {
    16  	*cfg.Common
    17  
    18  	apiID  string
    19  	apiKey string
    20  	team   string
    21  }
    22  
    23  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    24  	settings := Settings{
    25  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    26  
    27  		apiID:  ymlConfig.UString("apiID", os.Getenv("WTF_VICTOROPS_API_ID")),
    28  		apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_VICTOROPS_API_KEY"))),
    29  		team:   ymlConfig.UString("team"),
    30  	}
    31  
    32  	cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load()
    33  
    34  	return &settings
    35  }