1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Clean up the NewRelic module's API credentials loading

This commit is contained in:
Chris Cummer 2018-07-31 14:17:30 -07:00
parent ddd3eb9625
commit a1c528e4d5
2 changed files with 10 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import (
)
func Application() (*nr.Application, error) {
client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY"))
client := nr.NewClient(apiKey())
application, err := client.GetApplication(wtf.Config.UInt("wtf.mods.newrelic.applicationId"))
if err != nil {
@ -19,7 +19,7 @@ func Application() (*nr.Application, error) {
}
func Deployments() ([]nr.ApplicationDeployment, error) {
client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY"))
client := nr.NewClient(apiKey())
opts := &nr.ApplicationDeploymentOptions{Page: 1}
deployments, err := client.GetApplicationDeployments(wtf.Config.UInt("wtf.mods.newrelic.applicationId"), opts)
@ -29,3 +29,10 @@ func Deployments() ([]nr.ApplicationDeployment, error) {
return deployments, nil
}
func apiKey() string {
return wtf.Config.UString(
"wtf.mods.newrelic.apiKey",
os.Getenv("WTF_NEW_RELIC_API_KEY"),
)
}

View File

@ -31,7 +31,7 @@ func (widget *Widget) Refresh() {
}
widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf("%s- [green]%s[white]", widget.Name, appName))
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.Name, appName)))
widget.View.Clear()
var content string