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

     1  package newrelic
     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     = "NewRelic"
    13  )
    14  
    15  type Settings struct {
    16  	*cfg.Common
    17  
    18  	apiKey         string        `help:"Your New Relic API token."`
    19  	deployCount    int           `help:"The number of past deploys to display on screen." optional:"true"`
    20  	applicationIDs []interface{} `help:"The integer ID of the New Relic application you wish to report on."`
    21  }
    22  
    23  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    24  
    25  	settings := Settings{
    26  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    27  
    28  		apiKey:         ymlConfig.UString("apiKey", os.Getenv("WTF_NEW_RELIC_API_KEY")),
    29  		deployCount:    ymlConfig.UInt("deployCount", 5),
    30  		applicationIDs: ymlConfig.UList("applicationIDs"),
    31  	}
    32  
    33  	cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load()
    34  
    35  	return &settings
    36  }