mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
add ContainerWidgets interface, config channel
This commit is contained in:
26
config.go
26
config.go
@@ -4,20 +4,32 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
dockerHost string
|
||||
sortField string
|
||||
var configChan = make(chan ConfigMsg)
|
||||
|
||||
type Config map[string]string
|
||||
|
||||
type ConfigMsg struct {
|
||||
key string
|
||||
val string
|
||||
}
|
||||
|
||||
var DefaultConfig = NewDefaultConfig()
|
||||
func updateConfig(k, v string) {
|
||||
configChan <- ConfigMsg{k, v}
|
||||
}
|
||||
|
||||
func NewDefaultConfig() Config {
|
||||
docker := os.Getenv("DOCKER_HOST")
|
||||
if docker == "" {
|
||||
docker = "unix:///var/run/docker.sock"
|
||||
}
|
||||
return Config{
|
||||
dockerHost: docker,
|
||||
sortField: "id",
|
||||
config := Config{
|
||||
"dockerHost": docker,
|
||||
"sortField": "id",
|
||||
}
|
||||
go func() {
|
||||
for m := range configChan {
|
||||
config[m.key] = m.val
|
||||
}
|
||||
}()
|
||||
return config
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user