mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Merge pull request #244 from stokito/fix_243
#243 Fix bug: show ENV variables
This commit is contained in:
commit
0094cba5ea
@ -175,9 +175,7 @@ func (cm *Docker) refresh(c *container.Container) {
|
||||
c.SetMeta("ports", portsFormat(insp.NetworkSettings.Ports))
|
||||
c.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006"))
|
||||
c.SetMeta("health", insp.State.Health.Status)
|
||||
for _, env := range insp.Config.Env {
|
||||
c.SetMeta("[ENV-VAR]", env)
|
||||
}
|
||||
c.SetMeta("[ENV-VAR]", strings.Join(insp.Config.Env, ";"))
|
||||
c.SetState(insp.State.Status)
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package single
|
||||
import (
|
||||
ui "github.com/gizak/termui"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
||||
@ -23,14 +24,16 @@ func NewEnv() *Env {
|
||||
return i
|
||||
}
|
||||
|
||||
func (w *Env) Set(k, v string) {
|
||||
match := envPattern.FindStringSubmatch(v)
|
||||
key := match[1]
|
||||
value := match[2]
|
||||
w.data[key] = value
|
||||
|
||||
func (w *Env) Set(allEnvs string) {
|
||||
envs := strings.Split(allEnvs, ";")
|
||||
w.Rows = [][]string{}
|
||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||
for _, env := range envs {
|
||||
match := envPattern.FindStringSubmatch(env)
|
||||
key := match[1]
|
||||
value := match[2]
|
||||
w.data[key] = value
|
||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||
}
|
||||
|
||||
w.Height = len(w.Rows) + 2
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ func (e *Single) SetWidth(w int) { e.Width = w }
|
||||
func (e *Single) SetMeta(m models.Meta) {
|
||||
for k, v := range m {
|
||||
if k == "[ENV-VAR]" {
|
||||
e.Env.Set(k, v)
|
||||
e.Env.Set(v)
|
||||
} else {
|
||||
e.Info.Set(k, v)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user