mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplify the inclusion of the Common config settings into each module
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -12,7 +12,7 @@ const (
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
objects []string `help:"Kubernetes objects to show. Options are: [nodes, pods, deployments]."`
|
||||
title string `help:"Override the title of widget."`
|
||||
@@ -24,7 +24,7 @@ type Settings struct {
|
||||
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
|
||||
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
|
||||
|
||||
objects: utils.ToStrs(moduleConfig.UList("objects")),
|
||||
title: moduleConfig.UString("title"),
|
||||
|
||||
@@ -25,7 +25,7 @@ type Widget struct {
|
||||
// NewWidget creates a new instance of the widget
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.common),
|
||||
TextWidget: view.NewTextWidget(app, nil, settings.Common),
|
||||
|
||||
objects: settings.objects,
|
||||
title: settings.title,
|
||||
@@ -58,7 +58,7 @@ func (widget *Widget) Refresh() {
|
||||
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting node data [white]\n", true })
|
||||
return
|
||||
}
|
||||
content += fmt.Sprintf("[%s]Nodes[white]\n", widget.settings.common.Colors.Subheading)
|
||||
content += fmt.Sprintf("[%s]Nodes[white]\n", widget.settings.Colors.Subheading)
|
||||
for _, node := range nodeList {
|
||||
content += fmt.Sprintf("%s\n", node)
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (widget *Widget) Refresh() {
|
||||
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting deployment data [white]\n", true })
|
||||
return
|
||||
}
|
||||
content += fmt.Sprintf("[%s]Deployments[white]\n", widget.settings.common.Colors.Subheading)
|
||||
content += fmt.Sprintf("[%s]Deployments[white]\n", widget.settings.Colors.Subheading)
|
||||
for _, deployment := range deploymentList {
|
||||
content += fmt.Sprintf("%s\n", deployment)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (widget *Widget) Refresh() {
|
||||
widget.Redraw(func() (string, string, bool) { return title, "[red] Error getting pod data [white]\n", false })
|
||||
return
|
||||
}
|
||||
content += fmt.Sprintf("[%s]Pods[white]\n", widget.settings.common.Colors.Subheading)
|
||||
content += fmt.Sprintf("[%s]Pods[white]\n", widget.settings.Colors.Subheading)
|
||||
for _, pod := range podList {
|
||||
content += fmt.Sprintf("%s\n", pod)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user