ctop/connector/main.go

27 lines
523 B
Go
Raw Normal View History

2017-06-08 15:01:08 +00:00
package connector
import (
2017-06-14 13:11:40 +00:00
"fmt"
2017-06-08 15:01:08 +00:00
"github.com/bcicen/ctop/container"
"github.com/bcicen/ctop/logging"
)
var log = logging.Init()
2017-06-14 13:11:40 +00:00
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
}
2017-06-09 17:35:29 +00:00
type Connector interface {
2017-06-08 15:01:08 +00:00
All() container.Containers
Get(string) (*container.Container, bool)
}