ctop/connector/main.go
2018-01-29 12:47:10 +00:00

30 lines
577 B
Go

package connector
import (
"fmt"
"github.com/bcicen/ctop/container"
"github.com/bcicen/ctop/logging"
)
var (
log = logging.Init()
enabled = make(map[string]func() Connector)
)
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)
}
return enabled[s](), nil
}
type Connector interface {
All() container.Containers
Get(string) (*container.Container, bool)
}