util/syspolicy/setting: make setting.RawItem JSON-marshallable

We add setting.RawValue, a new type that facilitates unmarshalling JSON numbers and arrays
as uint64 and []string (instead of float64 and []any) for policy setting values.
We then use it to make setting.RawItem JSON-marshallable and update the tests.

Updates #12687

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2024-10-29 11:24:46 -05:00
committed by Nick Khyl
parent 2cc1100d24
commit 2a2228f97b
4 changed files with 336 additions and 141 deletions

View File

@@ -36,7 +36,7 @@ func ValueOf[T any](v T) Value[T] {
}
// String implements [fmt.Stringer].
func (o *Value[T]) String() string {
func (o Value[T]) String() string {
if !o.set {
return fmt.Sprintf("(empty[%T])", o.value)
}