This commit is contained in:
R Sivaram 2026-07-11 13:02:14 +05:30 committed by GitHub
commit 28dc4f9cc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -142,6 +142,10 @@ type GuiConfig struct {
// Window border style.
// One of 'rounded' (default) | 'single' | 'double' | 'hidden'
Border string `yaml:"border"`
// SortEnv sorts the container Env panel alphabetically by key. Default false
// preserves the insertion order from the image / compose file.
SortEnv bool `yaml:"sortEnv,omitempty"`
}
// CommandTemplatesConfig determines what commands actually get called when we

View file

@ -3,6 +3,7 @@ package gui
import (
"context"
"fmt"
"sort"
"strings"
"time"
@ -155,7 +156,23 @@ func (gui *Gui) containerEnv(container *commands.Container) string {
return gui.Tr.NothingToDisplay
}
envVarsList := lo.Map(container.Details.Config.Env, func(envVar string, _ int) []string {
envVars := container.Details.Config.Env
if gui.Config.UserConfig.Gui.SortEnv {
envVars = append([]string(nil), envVars...)
sort.SliceStable(envVars, func(i, j int) bool {
ki := envVars[i]
if idx := strings.IndexByte(ki, '='); idx >= 0 {
ki = ki[:idx]
}
kj := envVars[j]
if idx := strings.IndexByte(kj, '='); idx >= 0 {
kj = kj[:idx]
}
return ki < kj
})
}
envVarsList := lo.Map(envVars, func(envVar string, _ int) []string {
splitEnv := strings.SplitN(envVar, "=", 2)
key := splitEnv[0]
value := ""