1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-28 15:15:15 -07:00

WTF-400 NewRelic extracted to new config format

This commit is contained in:
Chris Cummer
2019-04-15 21:01:25 -07:00
parent 8ad8d942d0
commit b6d845b734
4 changed files with 43 additions and 14 deletions

View File

@@ -2,7 +2,6 @@ package newrelic
import (
"fmt"
"os"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
@@ -11,15 +10,20 @@ import (
type Widget struct {
wtf.TextWidget
client *Client
client *Client
settings *Settings
}
func NewWidget(app *tview.Application) *Widget {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, "New Relic", "newrelic", false),
client: NewClient(apiKey(), wtf.Config.UInt("wtf.mods.newrelic.applicationId")),
settings: settings,
}
widget.client = NewClient(widget.settings.apiKey, widget.settings.applicationID)
return &widget
}
@@ -81,7 +85,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
revisions = append(revisions, deploy.Revision)
if len(revisions) == wtf.Config.UInt("wtf.mods.newrelic.deployCount", 5) {
if len(revisions) == widget.settings.deployCount {
break
}
}
@@ -89,10 +93,3 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
return str
}
func apiKey() string {
return wtf.Config.UString(
"wtf.mods.newrelic.apiKey",
os.Getenv("WTF_NEW_RELIC_API_KEY"),
)
}