mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
50 lines
856 B
Go
50 lines
856 B
Go
package config
|
|
|
|
// defaults
|
|
var params = []*Param{
|
|
&Param{
|
|
Key: "dockerHost",
|
|
Val: getEnv("DOCKER_HOST", "unix:///var/run/docker.sock"),
|
|
Label: "Docker API URL",
|
|
},
|
|
&Param{
|
|
Key: "filterStr",
|
|
Val: "",
|
|
Label: "Container Name or ID Filter",
|
|
},
|
|
&Param{
|
|
Key: "sortField",
|
|
Val: "id",
|
|
Label: "Container Sort Field",
|
|
},
|
|
}
|
|
|
|
type Param struct {
|
|
Key string
|
|
Val string
|
|
Label string
|
|
}
|
|
|
|
// Get Param by key
|
|
func Get(k string) *Param {
|
|
for _, p := range GlobalParams {
|
|
if p.Key == k {
|
|
return p
|
|
}
|
|
}
|
|
return &Param{} // default
|
|
}
|
|
|
|
// Get Param value by key
|
|
func GetVal(k string) string {
|
|
return Get(k).Val
|
|
}
|
|
|
|
// Set param value
|
|
func Update(k, v string) {
|
|
p := Get(k)
|
|
log.Noticef("config change: %s: %s -> %s", k, quote(p.Val), quote(v))
|
|
p.Val = v
|
|
// log.Errorf("ignoring update for non-existant parameter: %s", k)
|
|
}
|