mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
5ec02f760e
The option is never worked and can't properly work because almost all containers anyway using Ash/Dash from /bin/sh
56 lines
929 B
Go
56 lines
929 B
Go
package config
|
|
|
|
// defaults
|
|
var defaultParams = []*Param{
|
|
&Param{
|
|
Key: "filterStr",
|
|
Val: "",
|
|
Label: "Container Name or ID Filter",
|
|
},
|
|
&Param{
|
|
Key: "sortField",
|
|
Val: "state",
|
|
Label: "Container Sort Field",
|
|
},
|
|
&Param{
|
|
Key: "columns",
|
|
Val: "status,name,id,cpu,mem,net,io,pids",
|
|
Label: "Enabled Columns",
|
|
},
|
|
}
|
|
|
|
type Param struct {
|
|
Key string
|
|
Val string
|
|
Label string
|
|
}
|
|
|
|
// Get Param by key
|
|
func Get(k string) *Param {
|
|
lock.RLock()
|
|
defer lock.RUnlock()
|
|
|
|
for _, p := range GlobalParams {
|
|
if p.Key == k {
|
|
return p
|
|
}
|
|
}
|
|
return &Param{} // default
|
|
}
|
|
|
|
// GetVal gets 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))
|
|
|
|
lock.Lock()
|
|
defer lock.Unlock()
|
|
p.Val = v
|
|
// log.Errorf("ignoring update for non-existant parameter: %s", k)
|
|
}
|