mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
refactor enabled connectors
This commit is contained in:
parent
01a305d326
commit
ac1ce18143
@ -11,6 +11,8 @@ import (
|
|||||||
api "github.com/fsouza/go-dockerclient"
|
api "github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() { enabled["docker"] = NewDocker }
|
||||||
|
|
||||||
type Docker struct {
|
type Docker struct {
|
||||||
client *api.Client
|
client *api.Client
|
||||||
containers map[string]*container.Container
|
containers map[string]*container.Container
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
// +build !linux
|
|
||||||
|
|
||||||
package connector
|
|
||||||
|
|
||||||
var enabled = map[string]func() Connector{
|
|
||||||
"docker": NewDocker,
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
// +build !darwin
|
|
||||||
|
|
||||||
package connector
|
|
||||||
|
|
||||||
var enabled = map[string]func() Connector{
|
|
||||||
"docker": NewDocker,
|
|
||||||
"runc": NewRunc,
|
|
||||||
}
|
|
@ -7,7 +7,10 @@ import (
|
|||||||
"github.com/bcicen/ctop/logging"
|
"github.com/bcicen/ctop/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Init()
|
var (
|
||||||
|
log = logging.Init()
|
||||||
|
enabled = make(map[string]func() Connector)
|
||||||
|
)
|
||||||
|
|
||||||
func ByName(s string) (Connector, error) {
|
func ByName(s string) (Connector, error) {
|
||||||
if _, ok := enabled[s]; !ok {
|
if _, ok := enabled[s]; !ok {
|
||||||
|
@ -14,11 +14,13 @@ import (
|
|||||||
"github.com/nu7hatch/gouuid"
|
"github.com/nu7hatch/gouuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() { enabled["mock"] = NewMock }
|
||||||
|
|
||||||
type Mock struct {
|
type Mock struct {
|
||||||
containers container.Containers
|
containers container.Containers
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMock() *Mock {
|
func NewMock() Connector {
|
||||||
cs := &Mock{}
|
cs := &Mock{}
|
||||||
go cs.Init()
|
go cs.Init()
|
||||||
go cs.Loop()
|
go cs.Loop()
|
||||||
|
@ -17,6 +17,8 @@ import (
|
|||||||
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
|
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() { enabled["runc"] = NewRunc }
|
||||||
|
|
||||||
type RuncOpts struct {
|
type RuncOpts struct {
|
||||||
root string // runc root path
|
root string // runc root path
|
||||||
systemdCgroups bool // use systemd cgroups
|
systemdCgroups bool // use systemd cgroups
|
||||||
|
Loading…
x
Reference in New Issue
Block a user