2017-02-16 03:02:13 +00:00
|
|
|
package config
|
|
|
|
|
2017-02-16 03:49:41 +00:00
|
|
|
// defaults
|
2017-02-16 03:02:13 +00:00
|
|
|
var switches = []*Switch{
|
|
|
|
&Switch{
|
2017-02-16 04:06:05 +00:00
|
|
|
Key: "sortReversed",
|
|
|
|
Val: false,
|
|
|
|
Label: "Reverse Sort Order",
|
2017-02-16 03:02:13 +00:00
|
|
|
},
|
|
|
|
&Switch{
|
2017-02-16 04:06:05 +00:00
|
|
|
Key: "allContainers",
|
2017-02-19 03:58:42 +00:00
|
|
|
Val: true,
|
2017-02-16 04:06:05 +00:00
|
|
|
Label: "Show All Containers",
|
2017-02-16 03:02:13 +00:00
|
|
|
},
|
|
|
|
&Switch{
|
2017-02-16 04:06:05 +00:00
|
|
|
Key: "enableHeader",
|
2017-02-19 03:58:42 +00:00
|
|
|
Val: true,
|
2017-03-08 23:40:35 +00:00
|
|
|
Label: "Enable Status Header",
|
2017-02-16 03:02:13 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
type Switch struct {
|
2017-02-16 04:06:05 +00:00
|
|
|
Key string
|
|
|
|
Val bool
|
|
|
|
Label string
|
2017-02-16 03:02:13 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 04:06:05 +00:00
|
|
|
// Return Switch by key
|
|
|
|
func GetSwitch(k string) *Switch {
|
2017-02-16 03:49:41 +00:00
|
|
|
for _, sw := range GlobalSwitches {
|
2017-02-16 04:06:05 +00:00
|
|
|
if sw.Key == k {
|
|
|
|
return sw
|
2017-02-16 03:49:41 +00:00
|
|
|
}
|
2017-02-16 03:02:13 +00:00
|
|
|
}
|
2017-02-16 04:06:05 +00:00
|
|
|
return &Switch{} // default
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return Switch value by key
|
|
|
|
func GetSwitchVal(k string) bool {
|
|
|
|
return GetSwitch(k).Val
|
2017-02-16 03:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle a boolean switch
|
|
|
|
func Toggle(k string) {
|
2017-02-16 04:06:05 +00:00
|
|
|
sw := GetSwitch(k)
|
|
|
|
newVal := sw.Val != true
|
|
|
|
log.Noticef("config change: %s: %t -> %t", k, sw.Val, newVal)
|
|
|
|
sw.Val = newVal
|
|
|
|
//log.Errorf("ignoring toggle for non-existant switch: %s", k)
|
2017-02-16 03:02:13 +00:00
|
|
|
}
|