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:
parent
ddd3eb9625
commit
a1c528e4d5
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Application() (*nr.Application, error) {
|
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"))
|
application, err := client.GetApplication(wtf.Config.UInt("wtf.mods.newrelic.applicationId"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -19,7 +19,7 @@ func Application() (*nr.Application, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Deployments() ([]nr.ApplicationDeployment, 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}
|
opts := &nr.ApplicationDeploymentOptions{Page: 1}
|
||||||
deployments, err := client.GetApplicationDeployments(wtf.Config.UInt("wtf.mods.newrelic.applicationId"), opts)
|
deployments, err := client.GetApplicationDeployments(wtf.Config.UInt("wtf.mods.newrelic.applicationId"), opts)
|
||||||
@ -29,3 +29,10 @@ func Deployments() ([]nr.ApplicationDeployment, error) {
|
|||||||
|
|
||||||
return deployments, nil
|
return deployments, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func apiKey() string {
|
||||||
|
return wtf.Config.UString(
|
||||||
|
"wtf.mods.newrelic.apiKey",
|
||||||
|
os.Getenv("WTF_NEW_RELIC_API_KEY"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -31,7 +31,7 @@ func (widget *Widget) Refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget.UpdateRefreshedAt()
|
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()
|
widget.View.Clear()
|
||||||
|
|
||||||
var content string
|
var content string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user