2017-01-03 17:37:09 +00:00
|
|
|
package main
|
|
|
|
|
2017-01-04 17:50:49 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2017-01-06 12:59:45 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-01-06 12:59:45 +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"
|
|
|
|
}
|
2017-01-06 12:59:45 +00:00
|
|
|
config := Config{
|
|
|
|
"dockerHost": docker,
|
|
|
|
"sortField": "id",
|
2017-01-03 17:37:09 +00:00
|
|
|
}
|
2017-01-06 12:59:45 +00:00
|
|
|
go func() {
|
|
|
|
for m := range configChan {
|
|
|
|
config[m.key] = m.val
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return config
|
2017-01-03 17:37:09 +00:00
|
|
|
}
|