mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Merge pull request #295 from glendsoza/master
Created a seperate context to display just environment variables
This commit is contained in:
commit
e9d65eda03
8 changed files with 80 additions and 10 deletions
|
|
@ -18,11 +18,11 @@ import (
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) getContainerContexts() []string {
|
func (gui *Gui) getContainerContexts() []string {
|
||||||
return []string{"logs", "stats", "config", "top"}
|
return []string{"logs", "stats", "env", "config", "top"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getContainerContextTitles() []string {
|
func (gui *Gui) getContainerContextTitles() []string {
|
||||||
return []string{gui.Tr.LogsTitle, gui.Tr.StatsTitle, gui.Tr.ConfigTitle, gui.Tr.TopTitle}
|
return []string{gui.Tr.LogsTitle, gui.Tr.StatsTitle, gui.Tr.EnvTitle, gui.Tr.ConfigTitle, gui.Tr.TopTitle}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getSelectedContainer() (*commands.Container, error) {
|
func (gui *Gui) getSelectedContainer() (*commands.Container, error) {
|
||||||
|
|
@ -75,6 +75,10 @@ func (gui *Gui) handleContainerSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
if err := gui.renderContainerConfig(container); err != nil {
|
if err := gui.renderContainerConfig(container); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
case "env":
|
||||||
|
if err := gui.renderContainerEnv(container); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
case "stats":
|
case "stats":
|
||||||
if err := gui.renderContainerStats(container); err != nil {
|
if err := gui.renderContainerStats(container); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -90,6 +94,33 @@ func (gui *Gui) handleContainerSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) renderContainerEnv(container *commands.Container) error {
|
||||||
|
mainView := gui.getMainView()
|
||||||
|
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.SplitN(env, "=", 2)
|
||||||
|
envVariablesList = append(envVariablesList,
|
||||||
|
[]string{
|
||||||
|
utils.ColoredString(splitEnv[0]+":", color.FgGreen),
|
||||||
|
utils.ColoredString(splitEnv[1], color.FgYellow),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
renderedTable, err = utils.RenderTable(envVariablesList)
|
||||||
|
if err != nil {
|
||||||
|
gui.Log.Error(err)
|
||||||
|
renderedTable = gui.Tr.CannotDisplayEnvVariables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gui.T.NewTask(func(stop chan struct{}) {
|
||||||
|
gui.renderString(gui.g, "main", renderedTable)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderContainerConfig(container *commands.Container) error {
|
func (gui *Gui) renderContainerConfig(container *commands.Container) error {
|
||||||
mainView := gui.getMainView()
|
mainView := gui.getMainView()
|
||||||
mainView.Autoscroll = false
|
mainView.Autoscroll = false
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,16 @@ import (
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) getServiceContexts() []string {
|
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 {
|
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) {
|
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 {
|
if err := gui.renderServiceStats(service); err != nil {
|
||||||
return err
|
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":
|
case "container-config":
|
||||||
if service.Container == nil {
|
if service.Container == nil {
|
||||||
return gui.renderString(gui.g, "main", gui.Tr.NoContainer)
|
return gui.renderString(gui.g, "main", gui.Tr.NoContainer)
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,15 @@ func dutchSet() TranslationSet {
|
||||||
ErrorTitle: "Fout",
|
ErrorTitle: "Fout",
|
||||||
LogsTitle: "Logs",
|
LogsTitle: "Logs",
|
||||||
ConfigTitle: "Config",
|
ConfigTitle: "Config",
|
||||||
|
EnvTitle: "Env",
|
||||||
DockerComposeConfigTitle: "Docker-Compose Configuratie",
|
DockerComposeConfigTitle: "Docker-Compose Configuratie",
|
||||||
TopTitle: "Top",
|
TopTitle: "Top",
|
||||||
StatsTitle: "Stats",
|
StatsTitle: "Stats",
|
||||||
CreditsTitle: "Over",
|
CreditsTitle: "Over",
|
||||||
ContainerConfigTitle: "Container Configuratie",
|
ContainerConfigTitle: "Container Configuratie",
|
||||||
|
ContainerEnvTitle: "Container Env",
|
||||||
|
NothingToDisplay: "Nothing to display",
|
||||||
|
CannotDisplayEnvVariables: "Something went wrong while displaying environment variables",
|
||||||
|
|
||||||
NoContainers: "Geen containers",
|
NoContainers: "Geen containers",
|
||||||
NoContainer: "Geen container",
|
NoContainer: "Geen container",
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,16 @@ type TranslationSet struct {
|
||||||
OpenInBrowser string
|
OpenInBrowser string
|
||||||
SortContainersByState string
|
SortContainersByState string
|
||||||
|
|
||||||
LogsTitle string
|
LogsTitle string
|
||||||
ConfigTitle string
|
ConfigTitle string
|
||||||
DockerComposeConfigTitle string
|
EnvTitle string
|
||||||
StatsTitle string
|
DockerComposeConfigTitle string
|
||||||
CreditsTitle string
|
StatsTitle string
|
||||||
ContainerConfigTitle string
|
CreditsTitle string
|
||||||
|
ContainerConfigTitle string
|
||||||
|
ContainerEnvTitle string
|
||||||
|
NothingToDisplay string
|
||||||
|
CannotDisplayEnvVariables string
|
||||||
|
|
||||||
No string
|
No string
|
||||||
Yes string
|
Yes string
|
||||||
|
|
@ -168,11 +172,15 @@ func englishSet() TranslationSet {
|
||||||
ErrorTitle: "Error",
|
ErrorTitle: "Error",
|
||||||
LogsTitle: "Logs",
|
LogsTitle: "Logs",
|
||||||
ConfigTitle: "Config",
|
ConfigTitle: "Config",
|
||||||
|
EnvTitle: "Env",
|
||||||
DockerComposeConfigTitle: "Docker-Compose Config",
|
DockerComposeConfigTitle: "Docker-Compose Config",
|
||||||
TopTitle: "Top",
|
TopTitle: "Top",
|
||||||
StatsTitle: "Stats",
|
StatsTitle: "Stats",
|
||||||
CreditsTitle: "About",
|
CreditsTitle: "About",
|
||||||
ContainerConfigTitle: "Container Config",
|
ContainerConfigTitle: "Container Config",
|
||||||
|
ContainerEnvTitle: "Container Env",
|
||||||
|
NothingToDisplay: "Nothing to display",
|
||||||
|
CannotDisplayEnvVariables: "Something went wrong while displaying environment variables",
|
||||||
|
|
||||||
NoContainers: "No containers",
|
NoContainers: "No containers",
|
||||||
NoContainer: "No container",
|
NoContainer: "No container",
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,15 @@ func germanSet() TranslationSet {
|
||||||
ErrorTitle: "Fehler",
|
ErrorTitle: "Fehler",
|
||||||
LogsTitle: "Protokoll",
|
LogsTitle: "Protokoll",
|
||||||
ConfigTitle: "Konfiguration",
|
ConfigTitle: "Konfiguration",
|
||||||
|
EnvTitle: "Env",
|
||||||
DockerComposeConfigTitle: "Docker-Compose Konfiguration",
|
DockerComposeConfigTitle: "Docker-Compose Konfiguration",
|
||||||
TopTitle: "Top",
|
TopTitle: "Top",
|
||||||
StatsTitle: "Statistiken",
|
StatsTitle: "Statistiken",
|
||||||
CreditsTitle: "Über Uns",
|
CreditsTitle: "Über Uns",
|
||||||
ContainerConfigTitle: "Container Konfiguration",
|
ContainerConfigTitle: "Container Konfiguration",
|
||||||
|
ContainerEnvTitle: "Container Env",
|
||||||
|
NothingToDisplay: "Nothing to display",
|
||||||
|
CannotDisplayEnvVariables: "Something went wrong while displaying environment variables",
|
||||||
|
|
||||||
NoContainers: "Keine Container",
|
NoContainers: "Keine Container",
|
||||||
NoContainer: "Kein Container",
|
NoContainer: "Kein Container",
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,15 @@ func polishSet() TranslationSet {
|
||||||
ErrorTitle: "Błąd",
|
ErrorTitle: "Błąd",
|
||||||
LogsTitle: "Logi",
|
LogsTitle: "Logi",
|
||||||
ConfigTitle: "Konfiguracja",
|
ConfigTitle: "Konfiguracja",
|
||||||
|
EnvTitle: "Env",
|
||||||
DockerComposeConfigTitle: "Konfiguracja docker-compose",
|
DockerComposeConfigTitle: "Konfiguracja docker-compose",
|
||||||
TopTitle: "Top",
|
TopTitle: "Top",
|
||||||
StatsTitle: "Staty",
|
StatsTitle: "Staty",
|
||||||
CreditsTitle: "O",
|
CreditsTitle: "O",
|
||||||
ContainerConfigTitle: "Konfiguracja kontenera",
|
ContainerConfigTitle: "Konfiguracja kontenera",
|
||||||
|
ContainerEnvTitle: "Container Env",
|
||||||
|
NothingToDisplay: "Nothing to display",
|
||||||
|
CannotDisplayEnvVariables: "Something went wrong while displaying environment variables",
|
||||||
|
|
||||||
NoContainers: "Brak kontenerów",
|
NoContainers: "Brak kontenerów",
|
||||||
NoContainer: "Brak kontenera",
|
NoContainer: "Brak kontenera",
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,15 @@ func turkishSet() TranslationSet {
|
||||||
ErrorTitle: "Hata",
|
ErrorTitle: "Hata",
|
||||||
LogsTitle: "Kayitlar",
|
LogsTitle: "Kayitlar",
|
||||||
ConfigTitle: "Ayarlar",
|
ConfigTitle: "Ayarlar",
|
||||||
|
EnvTitle: "Env",
|
||||||
DockerComposeConfigTitle: "Docker-Compose Ayar",
|
DockerComposeConfigTitle: "Docker-Compose Ayar",
|
||||||
TopTitle: "Top",
|
TopTitle: "Top",
|
||||||
StatsTitle: "Durumlar",
|
StatsTitle: "Durumlar",
|
||||||
CreditsTitle: "Hakkinda",
|
CreditsTitle: "Hakkinda",
|
||||||
ContainerConfigTitle: "Konteyner Ayar",
|
ContainerConfigTitle: "Konteyner Ayar",
|
||||||
|
ContainerEnvTitle: "Konteyner Env",
|
||||||
|
NothingToDisplay: "Nothing to display",
|
||||||
|
CannotDisplayEnvVariables: "Something went wrong while displaying environment variables",
|
||||||
|
|
||||||
NoContainers: "Konteynerler yok",
|
NoContainers: "Konteynerler yok",
|
||||||
NoContainer: "Konteyner yok",
|
NoContainer: "Konteyner yok",
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,9 @@ func renderDisplayableList(items []Displayable, config RenderListConfig) (string
|
||||||
|
|
||||||
// RenderTable takes an array of string arrays and returns a table containing the values
|
// RenderTable takes an array of string arrays and returns a table containing the values
|
||||||
func RenderTable(stringArrays [][]string) (string, error) {
|
func RenderTable(stringArrays [][]string) (string, error) {
|
||||||
|
if len(stringArrays) == 0 {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
if !displayArraysAligned(stringArrays) {
|
if !displayArraysAligned(stringArrays) {
|
||||||
return "", errors.New("Each item must return the same number of strings to display")
|
return "", errors.New("Each item must return the same number of strings to display")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue