Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Issue 33680043: Allow strings as bool/int config values (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by wallyworld
Modified:
10 years, 5 months ago
Reviewers:
mp+196819, fwereade, rog
Visibility:
Public.

Description

Allow strings as bool/int config values Fix the parsing of config values to allow suitable string values to be used to set bool and int attributes. eg "true" mean true, "42" means 42 etc. This is needed to allow juju set-env to work for those types of values. https://code.launchpad.net/~wallyworld/juju-core/set-env-boolean/+merge/196819 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+61 lines, -34 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/environment_test.go View 2 chunks +13 lines, -1 line 0 comments Download
M schema/schema.go View 3 chunks +24 lines, -23 lines 6 comments Download
M schema/schema_test.go View 3 chunks +22 lines, -10 lines 2 comments Download

Messages

Total messages: 6
wallyworld
Please take a look.
10 years, 5 months ago (2013-11-27 05:24:45 UTC) #1
rog
Looks good, thanks, with a few suggestions below. https://codereview.appspot.com/33680043/diff/1/schema/schema.go File schema/schema.go (right): https://codereview.appspot.com/33680043/diff/1/schema/schema.go#newcode105 schema/schema.go:105: if ...
10 years, 5 months ago (2013-11-27 09:00:07 UTC) #2
wallyworld
https://codereview.appspot.com/33680043/diff/1/schema/schema.go File schema/schema.go (right): https://codereview.appspot.com/33680043/diff/1/schema/schema.go#newcode105 schema/schema.go:105: if v != nil { On 2013/11/27 09:00:08, rog ...
10 years, 5 months ago (2013-11-27 09:40:17 UTC) #3
rog
On 27 November 2013 09:40, <ian.booth@canonical.com> wrote: > > https://codereview.appspot.com/33680043/diff/1/schema/schema.go > File schema/schema.go (right): > ...
10 years, 5 months ago (2013-11-27 10:14:39 UTC) #4
fwereade
On 2013/11/27 10:14:39, rog wrote: > Secondly, your code will accept any type at all, ...
10 years, 5 months ago (2013-11-27 22:58:22 UTC) #5
wallyworld
10 years, 5 months ago (2013-11-28 03:55:05 UTC) #6
https://codereview.appspot.com/33680043/diff/1/schema/schema.go
File schema/schema.go (right):

https://codereview.appspot.com/33680043/diff/1/schema/schema.go#newcode105
schema/schema.go:105: if v != nil {
On 2013/11/27 09:00:08, rog wrote:
> I think I'd be inclined to do something like this:
> 
> func (c boolC) Coerce(v interface{}, path []string) (interface{}, error) {
>     switch vv := reflect.TypeOf(v); vv.Kind() {
>     case reflect.Bool:
>         return vv.Bool(), nil
>     case reflect.String:
>         val, err := strconv.ParseBool(vv.String())
>         if err == nil {
>             return val, nil
>         }
>     }
>     return nil, error{"bool", v, path}
> }
> 
> the Sprintf seems unnecessary overkill.

Done.

https://codereview.appspot.com/33680043/diff/1/schema/schema.go#newcode123
schema/schema.go:123: if v != nil {
On 2013/11/27 09:00:08, rog wrote:
> similar here

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b