mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
Changes as requested per review
This commit is contained in:
parent
600e4af8e6
commit
4d90a0345f
8 changed files with 51 additions and 25 deletions
|
|
@ -99,26 +99,22 @@ func (gui *Gui) renderContainerEnv(container *commands.Container) error {
|
|||
mainView.Autoscroll = false
|
||||
mainView.Wrap = gui.Config.UserConfig.Gui.WrapMainPanel
|
||||
envVariablesList := [][]string{}
|
||||
renderedTable := gui.Tr.NothingToDisplay
|
||||
if len(container.Details.Config.Env) > 0 {
|
||||
var err error
|
||||
for _, env := range container.Details.Config.Env {
|
||||
splitEnv := strings.Split(env, "=")
|
||||
// if the value has = in it, lets say export "test=foo=bar" then split will result in the following
|
||||
// {"test", "foo","bar"} hence join all the elements in the slice except the first one to get value
|
||||
splitEnv := strings.SplitN(env, "=", 2)
|
||||
envVariablesList = append(envVariablesList,
|
||||
[]string{
|
||||
utils.ColoredString(splitEnv[0]+":", color.FgBlue),
|
||||
utils.ColoredString(strings.Join(splitEnv[1:], "="), color.FgYellow),
|
||||
utils.ColoredString(splitEnv[0]+":", color.FgGreen),
|
||||
utils.ColoredString(splitEnv[1], color.FgYellow),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
envVariablesList = append(envVariablesList, []string{"Nothing to display"})
|
||||
}
|
||||
renderedTable, err := utils.RenderTable(envVariablesList)
|
||||
// in case of some error
|
||||
if err != nil {
|
||||
// log the error
|
||||
gui.Log.Error(err)
|
||||
renderedTable = "Something went wrong while displaying environment variables"
|
||||
renderedTable, err = utils.RenderTable(envVariablesList)
|
||||
if err != nil {
|
||||
gui.Log.Error(err)
|
||||
renderedTable = gui.Tr.CannotDisplayEnvVairables
|
||||
}
|
||||
}
|
||||
return gui.T.NewTask(func(stop chan struct{}) {
|
||||
gui.renderString(gui.g, "main", renderedTable)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,16 @@ import (
|
|||
// list panel functions
|
||||
|
||||
func (gui *Gui) getServiceContexts() []string {
|
||||
return []string{"logs", "stats", "container-config", "top"}
|
||||
return []string{"logs", "stats", "container-env", "container-config", "top"}
|
||||
}
|
||||
|
||||
func (gui *Gui) getServiceContextTitles() []string {
|
||||
return []string{gui.Tr.LogsTitle, gui.Tr.StatsTitle, gui.Tr.ContainerConfigTitle, gui.Tr.TopTitle}
|
||||
return []string{
|
||||
gui.Tr.LogsTitle,
|
||||
gui.Tr.StatsTitle,
|
||||
gui.Tr.ContainerEnvTitle,
|
||||
gui.Tr.ContainerConfigTitle,
|
||||
gui.Tr.TopTitle}
|
||||
}
|
||||
|
||||
func (gui *Gui) getSelectedService() (*commands.Service, error) {
|
||||
|
|
@ -73,6 +78,13 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
|||
if err := gui.renderServiceStats(service); err != nil {
|
||||
return err
|
||||
}
|
||||
case "container-env":
|
||||
if service.Container == nil {
|
||||
return gui.renderString(gui.g, "main", gui.Tr.NoContainer)
|
||||
}
|
||||
if err := gui.renderContainerEnv(service.Container); err != nil {
|
||||
return err
|
||||
}
|
||||
case "container-config":
|
||||
if service.Container == nil {
|
||||
return gui.renderString(gui.g, "main", gui.Tr.NoContainer)
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ func dutchSet() TranslationSet {
|
|||
StatsTitle: "Stats",
|
||||
CreditsTitle: "Over",
|
||||
ContainerConfigTitle: "Container Configuratie",
|
||||
ContainerEnvTitle: "Container Env",
|
||||
NothingToDisplay: "Nothing to display",
|
||||
CannotDisplayEnvVairables: "Something went wrong while displaying environment variables",
|
||||
|
||||
NoContainers: "Geen containers",
|
||||
NoContainer: "Geen container",
|
||||
|
|
|
|||
|
|
@ -83,13 +83,16 @@ type TranslationSet struct {
|
|||
ViewBulkCommands string
|
||||
OpenInBrowser string
|
||||
|
||||
LogsTitle string
|
||||
ConfigTitle string
|
||||
EnvTitle string
|
||||
DockerComposeConfigTitle string
|
||||
StatsTitle string
|
||||
CreditsTitle string
|
||||
ContainerConfigTitle string
|
||||
LogsTitle string
|
||||
ConfigTitle string
|
||||
EnvTitle string
|
||||
DockerComposeConfigTitle string
|
||||
StatsTitle string
|
||||
CreditsTitle string
|
||||
ContainerConfigTitle string
|
||||
ContainerEnvTitle string
|
||||
NothingToDisplay string
|
||||
CannotDisplayEnvVairables string
|
||||
|
||||
No string
|
||||
Yes string
|
||||
|
|
@ -173,6 +176,9 @@ func englishSet() TranslationSet {
|
|||
StatsTitle: "Stats",
|
||||
CreditsTitle: "About",
|
||||
ContainerConfigTitle: "Container Config",
|
||||
ContainerEnvTitle: "Container Env",
|
||||
NothingToDisplay: "Nothing to display",
|
||||
CannotDisplayEnvVairables: "Something went wrong while displaying environment variables",
|
||||
|
||||
NoContainers: "No containers",
|
||||
NoContainer: "No container",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ func germanSet() TranslationSet {
|
|||
StatsTitle: "Statistiken",
|
||||
CreditsTitle: "Über Uns",
|
||||
ContainerConfigTitle: "Container Konfiguration",
|
||||
ContainerEnvTitle: "Container Env",
|
||||
NothingToDisplay: "Nothing to display",
|
||||
CannotDisplayEnvVairables: "Something went wrong while displaying environment variables",
|
||||
|
||||
NoContainers: "Keine Container",
|
||||
NoContainer: "Kein Container",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ func polishSet() TranslationSet {
|
|||
StatsTitle: "Staty",
|
||||
CreditsTitle: "O",
|
||||
ContainerConfigTitle: "Konfiguracja kontenera",
|
||||
ContainerEnvTitle: "Container Env",
|
||||
NothingToDisplay: "Nothing to display",
|
||||
CannotDisplayEnvVairables: "Something went wrong while displaying environment variables",
|
||||
|
||||
NoContainers: "Brak kontenerów",
|
||||
NoContainer: "Brak kontenera",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ func turkishSet() TranslationSet {
|
|||
StatsTitle: "Durumlar",
|
||||
CreditsTitle: "Hakkinda",
|
||||
ContainerConfigTitle: "Konteyner Ayar",
|
||||
ContainerEnvTitle: "Konteyner Env",
|
||||
NothingToDisplay: "Nothing to display",
|
||||
CannotDisplayEnvVairables: "Something went wrong while displaying environment variables",
|
||||
|
||||
NoContainers: "Konteynerler yok",
|
||||
NoContainer: "Konteyner yok",
|
||||
|
|
|
|||
|
|
@ -165,9 +165,9 @@ func renderDisplayableList(items []Displayable, config RenderListConfig) (string
|
|||
|
||||
// RenderTable takes an array of string arrays and returns a table containing the values
|
||||
func RenderTable(stringArrays [][]string) (string, error) {
|
||||
// if empty array is given then getPadWidths will panic hence check to make sure array is not empty
|
||||
// if empty array is given then getPadWidths will panic hence return an empty string
|
||||
if len(stringArrays) == 0 {
|
||||
return "", errors.New("RenderTable given an empty array")
|
||||
return "", nil
|
||||
}
|
||||
if !displayArraysAligned(stringArrays) {
|
||||
return "", errors.New("Each item must return the same number of strings to display")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue