config/spec: preserve nanosecond Duration wire format for v2

ConfigSpec.JSON() exports the flag specification as JSON. Duration-typed
default values (e.g. consensus timeouts) need to render as integer
nanoseconds for v1-compatible consumers and so the embedded JSON
fixtures roundtrip. Pass jsonv1.FormatDurationAsNano(true) at the
Marshal site.
This commit is contained in:
Hanzo AI
2026-06-06 23:06:31 -07:00
parent 6bc6ca2e69
commit 96fc5e58e5
+2 -1
View File
@@ -8,6 +8,7 @@ package spec
import (
"github.com/go-json-experiment/json"
jsonv1 "github.com/go-json-experiment/json/v1"
"github.com/go-json-experiment/json/jsontext"
"time"
)
@@ -208,7 +209,7 @@ func (s *ConfigSpec) DeprecatedFlags() []FlagSpec {
// JSON returns the spec as formatted JSON.
func (s *ConfigSpec) JSON() ([]byte, error) {
return json.Marshal(s, jsontext.WithIndent(" "))
return json.Marshal(s, jsontext.WithIndent(" "), jsonv1.FormatDurationAsNano(true))
}
// ValidateValue checks if a value is valid for a flag.