mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
extract captions to const
This commit is contained in:
parent
278cc6c03d
commit
68c2d3ad42
2 changed files with 9 additions and 4 deletions
|
|
@ -22,6 +22,11 @@ import (
|
||||||
"github.com/jesseduffield/yaml"
|
"github.com/jesseduffield/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CPUCaption = "CPU (%)"
|
||||||
|
MemoryCaption = "Memory (%)"
|
||||||
|
)
|
||||||
|
|
||||||
// UserConfig holds all of the user-configurable options
|
// UserConfig holds all of the user-configurable options
|
||||||
type UserConfig struct {
|
type UserConfig struct {
|
||||||
// Gui is for configuring visual things like colors and whether we show or
|
// Gui is for configuring visual things like colors and whether we show or
|
||||||
|
|
@ -460,12 +465,12 @@ func GetDefaultConfig() UserConfig {
|
||||||
MaxDuration: duration,
|
MaxDuration: duration,
|
||||||
Graphs: []GraphConfig{
|
Graphs: []GraphConfig{
|
||||||
{
|
{
|
||||||
Caption: "CPU (%)",
|
Caption: CPUCaption,
|
||||||
StatPath: "DerivedStats.CPUPercentage",
|
StatPath: "DerivedStats.CPUPercentage",
|
||||||
Color: "cyan",
|
Color: "cyan",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Caption: "Memory (%)",
|
Caption: MemoryCaption,
|
||||||
StatPath: "DerivedStats.MemoryPercentage",
|
StatPath: "DerivedStats.MemoryPercentage",
|
||||||
Color: "green",
|
Color: "green",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -93,14 +93,14 @@ func plotGraph(container *commands.Container, spec config.GraphConfig, width int
|
||||||
memoryLimit := utils.FormatDecimalBytes(int(container.StatHistory[dataLength-1].DerivedStats.MemoryLimit))
|
memoryLimit := utils.FormatDecimalBytes(int(container.StatHistory[dataLength-1].DerivedStats.MemoryLimit))
|
||||||
var caption string
|
var caption string
|
||||||
switch spec.Caption {
|
switch spec.Caption {
|
||||||
case "CPU (%)":
|
case config.CPUCaption:
|
||||||
caption = fmt.Sprintf(
|
caption = fmt.Sprintf(
|
||||||
"%s: %0.2f (%v)",
|
"%s: %0.2f (%v)",
|
||||||
spec.Caption,
|
spec.Caption,
|
||||||
data[dataLength-1],
|
data[dataLength-1],
|
||||||
time.Since(container.StatHistory[0].RecordedAt).Round(time.Second),
|
time.Since(container.StatHistory[0].RecordedAt).Round(time.Second),
|
||||||
)
|
)
|
||||||
case "Memory (%)":
|
case config.MemoryCaption:
|
||||||
caption = fmt.Sprintf(
|
caption = fmt.Sprintf(
|
||||||
"%s: %s / %s (%0.2f) (%v)",
|
"%s: %s / %s (%0.2f) (%v)",
|
||||||
spec.Caption,
|
spec.Caption,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue