Merge branch 'master' into inspect

This commit is contained in:
Sergey Ponomarev 2020-12-05 13:05:46 +02:00
commit 0fd18ec603
7 changed files with 14 additions and 16 deletions

View File

@ -1,4 +1,4 @@
FROM quay.io/vektorcloud/go:1.13
FROM quay.io/vektorcloud/go:1.15
RUN apk add --no-cache make

View File

@ -28,7 +28,7 @@ var defaultColumns = []Column{
},
Column{
Name: "cpus",
Label: "CPU Usage as % of system total",
Label: "CPU Usage (% of system total)",
Enabled: false,
},
Column{

View File

@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
@ -81,7 +82,7 @@ func Write() (path string, err error) {
return path, err
}
cfgdir := basedir(path)
cfgdir := filepath.Dir(path)
// create config dir if not exist
if _, err := os.Stat(cfgdir); err != nil {
err = os.MkdirAll(cfgdir, 0755)
@ -141,8 +142,3 @@ func xdgSupport() bool {
}
return false
}
func basedir(path string) string {
parts := strings.Split(path, "/")
return strings.Join((parts[0 : len(parts)-1]), "/")
}

View File

@ -47,9 +47,9 @@ func (l *DockerLogs) Stream() chan models.Log {
go func() {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
parts := strings.Split(scanner.Text(), " ")
parts := strings.SplitN(scanner.Text(), " ", 2)
ts := l.parseTime(parts[0])
logCh <- models.Log{Timestamp: ts, Message: strings.Join(parts[1:], " ")}
logCh <- models.Log{Timestamp: ts, Message: parts[1]}
}
}()
@ -74,12 +74,12 @@ func (l *DockerLogs) Stream() chan models.Log {
func (l *DockerLogs) Stop() { l.done <- true }
func (l *DockerLogs) parseTime(s string) time.Time {
ts, err := time.Parse("2006-01-02T15:04:05.000000000Z", s)
ts, err := time.Parse(time.RFC3339Nano, s)
if err == nil {
return ts
}
ts, err2 := time.Parse("2006-01-02T15:04:05.000000000Z", l.stripPfx(s))
ts, err2 := time.Parse(time.RFC3339Nano, l.stripPfx(s))
if err2 == nil {
return ts
}

View File

@ -290,5 +290,5 @@ func (cm *Docker) All() (containers container.Containers) {
// use primary container name
func shortName(name string) string {
return strings.Replace(name, "/", "", 1)
return strings.TrimPrefix(name, "/")
}

View File

@ -14,7 +14,9 @@ type NameCol struct {
}
func NewNameCol() CompactCol {
return &NameCol{NewTextCol("NAME")}
c := &NameCol{NewTextCol("NAME")}
c.fWidth = 30
return c
}
func (w *NameCol) SetMeta(m models.Meta) {

View File

@ -132,7 +132,7 @@ func ColumnsMenu() MenuFn {
m.Selectable = true
m.SortItems = false
m.BorderLabel = "Columns"
//m.SubText = "Enabled Columns"
m.SubText = "Re-order: <Page Up> / <Page Down>"
rebuild := func() {
// get padding for right alignment of enabled status
@ -261,7 +261,7 @@ func ContainerMenu() MenuFn {
ui.StopLoop()
})
}
if c.Meta["state"] != "exited" || c.Meta["state"] != "created" {
if c.Meta["state"] != "exited" && c.Meta["state"] != "created" {
ui.Handle("/sys/kbd/p", func(ui.Event) {
if c.Meta["state"] == "paused" {
selected = "unpause"