ctop/config.go

36 lines
514 B
Go
Raw Normal View History

2017-01-03 17:37:09 +00:00
package main
2017-01-04 17:50:49 +00:00
import (
"os"
)
var configChan = make(chan ConfigMsg)
type Config map[string]string
type ConfigMsg struct {
key string
val string
2017-01-03 17:37:09 +00:00
}
func updateConfig(k, v string) {
configChan <- ConfigMsg{k, v}
}
2017-01-03 17:37:09 +00:00
func NewDefaultConfig() Config {
2017-01-04 17:50:49 +00:00
docker := os.Getenv("DOCKER_HOST")
if docker == "" {
docker = "unix:///var/run/docker.sock"
}
config := Config{
"dockerHost": docker,
"sortField": "id",
2017-01-03 17:37:09 +00:00
}
go func() {
for m := range configChan {
config[m.key] = m.val
}
}()
return config
2017-01-03 17:37:09 +00:00
}