mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Annotate config option if changed and restart is required
This commit is contained in:
parent
6b2e20ca56
commit
e6903c65dc
2 changed files with 20 additions and 0 deletions
|
@ -94,6 +94,10 @@ const (
|
|||
// may be extended to hold references to other options in the
|
||||
// future.
|
||||
StackableAnnotation = "safing/portbase:options:stackable"
|
||||
// RestartPendingAnnotation is automatically set on a configuration option
|
||||
// that requires a restart and has been changed.
|
||||
// The value must always be a boolean with value "true".
|
||||
RestartPendingAnnotation = "safing/portbase:options:restart-pending"
|
||||
// QuickSettingAnnotation can be used to add quick settings to
|
||||
// a configuration option. A quick setting can support the user
|
||||
// by switching between pre-configured values.
|
||||
|
@ -258,6 +262,12 @@ func (option *Option) SetAnnotation(key string, value interface{}) {
|
|||
option.Lock()
|
||||
defer option.Unlock()
|
||||
|
||||
option.setAnnotation(key, value)
|
||||
}
|
||||
|
||||
// setAnnotation sets the value of the annotation key overwritting an
|
||||
// existing value if required. Does not lock the Option.
|
||||
func (option *Option) setAnnotation(key string, value interface{}) {
|
||||
if option.Annotations == nil {
|
||||
option.Annotations = make(Annotations)
|
||||
}
|
||||
|
|
|
@ -147,6 +147,11 @@ func setConfigOption(key string, value interface{}, push bool) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Add the "restart pending" annotation if the settings requires a restart.
|
||||
if option.RequiresRestart {
|
||||
option.setAnnotation(RestartPendingAnnotation, true)
|
||||
}
|
||||
|
||||
handleOptionUpdate(option, push)
|
||||
option.Unlock()
|
||||
|
||||
|
@ -182,6 +187,11 @@ func setDefaultConfigOption(key string, value interface{}, push bool) (err error
|
|||
}
|
||||
}
|
||||
|
||||
// Add the "restart pending" annotation if the settings requires a restart.
|
||||
if option.RequiresRestart {
|
||||
option.setAnnotation(RestartPendingAnnotation, true)
|
||||
}
|
||||
|
||||
handleOptionUpdate(option, push)
|
||||
option.Unlock()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue