Tags: juju/schema
Tags
Merge pull request #25 from SimonRichardson/encode-time-duration-as-s… …trings #25 The following is a fix for issues where we would like the properties of time.Duration schema coercion, but the result is always a string. The problem with using the time.Duration, is that it has no json encoding method. The consequence of this is that when time.Duration is passed over the wire, the json encoders treat values as float64. We then have no way to get back to a time.Duration without wrapping all the locations that we want a time.Duration that could be float64 in all call sites. Another solution would be to allow the TimeDuration to accept float64 and to do the right thing there except what if you want to prevent other floats from being accepted in that location. The schema coercion becomes too weak. All float64s are valid time.Durations. Unlike strings, they have to conform to a specific format that can be parsed correctly and more importantly rejected if they're wrong. --- I had to bump the go version as the test wouldn't run any more.