Compare commits

..

10 Commits
v0.7 ... v0.7.1

Author SHA1 Message Date
Bradley Cicenas
5261444265 v0.7.1 2018-03-09 05:19:34 +00:00
Bradley Cicenas
b3aa291182 update termbox-go dependency 2018-03-09 05:15:55 +00:00
Bradley Cicenas
051b474bf0 dep updates 2018-02-23 13:57:59 +09:30
Bradley Cicenas
fac6632459 build image from go 1.10 2018-02-22 14:58:21 +09:30
Bradley Cicenas
1c7cf98e58 handle window resize in help dialog 2018-02-02 15:21:33 +00:00
Bradley Cicenas
44a54e070d combine conditionals 2018-02-01 16:55:23 +00:00
Bradley Cicenas
10b9a6c013 include windows build 2018-01-31 17:05:54 +00:00
Bradley Cicenas
a3b67e4607 add available connectors to help dialog 2018-01-30 07:54:13 -03:00
Bradley Cicenas
ac1ce18143 refactor enabled connectors 2018-01-29 12:47:10 +00:00
bradley
01a305d326 Update README.md
escape brackets
2018-01-11 15:58:37 -03:00
17 changed files with 56 additions and 46 deletions

View File

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

14
Gopkg.lock generated
View File

@@ -6,6 +6,12 @@
packages = [".","winterm"]
revision = "fa152c58bc15761d0200cb75fe958b89a9d4888e"
[[projects]]
name = "github.com/BurntSushi/toml"
packages = ["."]
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
version = "v0.3.0"
[[projects]]
name = "github.com/Microsoft/go-winio"
packages = ["."]
@@ -57,10 +63,10 @@
revision = "318513eb1ab27495afbc67f671ba1080513d8aa0"
[[projects]]
branch = "barchart-numfmt"
branch = "master"
name = "github.com/gizak/termui"
packages = ["."]
revision = "ea10e6ccee219e572ffad0ac1909f1a17f6db7d6"
revision = "cdc199d7ea432fd8187db35f0247285d6f5b0267"
source = "https://github.com/bcicen/termui"
[[projects]]
@@ -106,7 +112,7 @@
[[projects]]
name = "github.com/nsf/termbox-go"
packages = ["."]
revision = "91bae1bb5fa9ee504905ecbe7043fa30e92feaa3"
revision = "e2050e41c8847748ec5288741c0b19a8cb26d084"
[[projects]]
branch = "master"
@@ -154,6 +160,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "cf4dacc32111b22d72ac23189b826c8316ec265e55bf987338c7a00633af788e"
inputs-digest = "f46f5c696ecb0b0c42a38dac512df21fc1f5fb2bfda888434e005e69d1b6273b"
solver-name = "gps-cdcl"
solver-version = 1

View File

@@ -26,7 +26,7 @@
revision = "318513eb1ab27495afbc67f671ba1080513d8aa0"
[[constraint]]
branch = "barchart-numfmt"
branch = "master"
name = "github.com/gizak/termui"
source = "https://github.com/bcicen/termui"

View File

@@ -16,10 +16,11 @@ build-dev:
build-all:
mkdir -p _build
GOOS=darwin GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-darwin-amd64
GOOS=linux GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-amd64
GOOS=linux GOARCH=arm go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm
GOOS=linux GOARCH=arm64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm64
GOOS=darwin GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-darwin-amd64
GOOS=linux GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-amd64
GOOS=linux GOARCH=arm go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm
GOOS=linux GOARCH=arm64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm64
GOOS=windows GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-windows-amd64
cd _build; sha256sum * > sha256sums.txt
image:

View File

@@ -63,7 +63,7 @@ While running, use `S` to save the current filters, sort field, and other option
Option | Description
--- | ---
-a | show active containers only
-f <string> | set an initial filter string
-f \<string\> | set an initial filter string
-h | display help dialog
-i | invert default colors
-r | reverse container sort order
@@ -75,7 +75,7 @@ Option | Description
Key | Action
--- | ---
<enter> | Open container menu
\<enter\> | Open container menu
a | Toggle display of all (running and non-running) containers
f | Filter displayed containers (`esc` to clear when open)
H | Toggle ctop header

View File

@@ -1 +1 @@
0.7
0.7.1

View File

@@ -1,4 +1,4 @@
// +build !darwin
// +build linux
package collector

View File

@@ -1,4 +1,4 @@
// +build !darwin
// +build linux
package collector

View File

@@ -11,6 +11,8 @@ import (
api "github.com/fsouza/go-dockerclient"
)
func init() { enabled["docker"] = NewDocker }
type Docker struct {
client *api.Client
containers map[string]*container.Container

View File

@@ -1,7 +0,0 @@
// +build !linux
package connector
var enabled = map[string]func() Connector{
"docker": NewDocker,
}

View File

@@ -1,8 +0,0 @@
// +build !darwin
package connector
var enabled = map[string]func() Connector{
"docker": NewDocker,
"runc": NewRunc,
}

View File

@@ -2,22 +2,31 @@ package connector
import (
"fmt"
"sort"
"github.com/bcicen/ctop/container"
"github.com/bcicen/ctop/logging"
)
var log = logging.Init()
var (
log = logging.Init()
enabled = make(map[string]func() Connector)
)
// return names for all enabled connectors on the current platform
func Enabled() (a []string) {
for k, _ := range enabled {
a = append(a, k)
}
sort.Strings(a)
return a
}
func ByName(s string) (Connector, error) {
if _, ok := enabled[s]; !ok {
msg := fmt.Sprintf("invalid connector type \"%s\"\nconnector must be one of:", s)
for k, _ := range enabled {
msg += fmt.Sprintf("\n %s", k)
}
return nil, fmt.Errorf(msg)
if cfn, ok := enabled[s]; ok {
return cfn(), nil
}
return enabled[s](), nil
return nil, fmt.Errorf("invalid connector type \"%s\"", s)
}
type Connector interface {

View File

@@ -14,11 +14,13 @@ import (
"github.com/nu7hatch/gouuid"
)
func init() { enabled["mock"] = NewMock }
type Mock struct {
containers container.Containers
}
func NewMock() *Mock {
func NewMock() Connector {
cs := &Mock{}
go cs.Init()
go cs.Loop()

View File

@@ -1,4 +1,4 @@
// +build !darwin
// +build linux
package connector
@@ -17,6 +17,8 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
)
func init() { enabled["runc"] = NewRunc }
type RuncOpts struct {
root string // runc root path
systemdCgroups bool // use systemd cgroups

View File

@@ -23,10 +23,7 @@ func NewCompactGrid() *CompactGrid {
func (cg *CompactGrid) Align() {
y := cg.Y
if cg.Offset >= len(cg.Rows) {
cg.Offset = 0
}
if cg.Offset < 0 {
if cg.Offset >= len(cg.Rows) || cg.Offset < 0 {
cg.Offset = 0
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
"strings"
"github.com/bcicen/ctop/config"
"github.com/bcicen/ctop/connector"
@@ -138,7 +139,7 @@ func panicExit() {
}
}
var helpMsg = `ctop - container metric viewer
var helpMsg = `ctop - interactive container viewer
usage: ctop [options]
@@ -148,4 +149,6 @@ options:
func printHelp() {
fmt.Println(helpMsg)
flag.PrintDefaults()
fmt.Printf("\navailable connectors: ")
fmt.Println(strings.Join(connector.Enabled(), ", "))
}

View File

@@ -37,7 +37,10 @@ func HelpMenu() MenuFn {
m := menu.NewMenu()
m.BorderLabel = "Help"
m.AddItems(helpDialog...)
ui.Render(m)
ui.Handle("/sys/wnd/resize", func(e ui.Event) {
ui.Clear()
ui.Render(m)
})
ui.Handle("/sys/kbd/", func(ui.Event) {
ui.StopLoop()
})