util/syspolicy: add read boolean setting (#9592)

This commit is contained in:
Claire Wang
2023-09-29 21:27:04 -04:00
committed by GitHub
parent 324f0d5f80
commit a56e58c244
7 changed files with 88 additions and 2 deletions

View File

@@ -27,6 +27,15 @@ func GetUint64(key Key, defaultValue uint64) (uint64, error) {
return v, err
}
func GetBoolean(key Key, defaultValue bool) (bool, error) {
markHandlerInUse()
v, err := handler.ReadBoolean(string(key))
if errors.Is(err, ErrNoSuchKey) {
return defaultValue, nil
}
return v, err
}
// PreferenceOption is a policy that governs whether a boolean variable
// is forcibly assigned an administrator-defined value, or allowed to receive
// a user-defined value.