Merge lp:~wallyworld/juju-core/set-env-boolean into lp:~go-bot/juju-core/trunk
Proposed by
Ian Booth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2103 | ||||
Proposed branch: | lp:~wallyworld/juju-core/set-env-boolean | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
184 lines (+75/-23) 4 files modified
cmd/juju/environment_test.go (+13/-1) environs/config/config_test.go (+2/-2) schema/schema.go (+34/-10) schema/schema_test.go (+26/-10) |
||||
To merge this branch: | bzr merge lp:~wallyworld/juju-core/set-env-boolean | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+196819@code.launchpad.net |
Commit message
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.
Description of the change
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.
To post a comment you must log in.
Reviewers: mp+196819_ code.launchpad. net,
Message:
Please take a look.
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/~wallyworl d/juju- core/set- env-boolean/ +merge/ 196819
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/33680043/
Affected files (+61, -34 lines): environment_ test.go schema_ test.go
A [revision details]
M cmd/juju/
M schema/schema.go
M schema/
Index: [revision details] 20131126164544- 1janyqs4x0e2mt9 l
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: schema/schema.go
=== modified file 'schema/schema.go'
--- schema/schema.go 2013-09-26 23:26:19 +0000
+++ schema/schema.go 2013-11-27 05:21:41 +0000
@@ -102,8 +102,11 @@
type boolC struct{}
func (c boolC) Coerce(v interface{}, path []string) (interface{}, error) { TypeOf( v).Kind( ) == reflect.Bool { ParseBool( fmt.Sprintf( "%v", v))
- if v != nil && reflect.
- return v, nil
+ if v != nil {
+ val, err := strconv.
+ if err == nil {
+ return val, nil
+ }
}
return nil, error_{"bool", v, path}
}
@@ -117,19 +120,13 @@
type intC struct{}
func (c intC) Coerce(v interface{}, path []string) (interface{}, error) { TypeOf( v).Kind( ) { ValueOf( v).Int( ), nil ParseInt( fmt.Sprintf( "%v", v), 0, 64)
- if v == nil {
- return nil, error_{"int", v, path}
- }
- switch reflect.
- case reflect.Int:
- case reflect.Int8:
- case reflect.Int16:
- case reflect.Int32:
- case reflect.Int64:
- default:
- return nil, error_{"int", v, path}
- }
- return reflect.
+ if v != nil {
+ val, err := strconv.
+ if err == nil {
+ return val, nil
+ }
+ }
+ return nil, error_{"int", v, path}
}
// ForceInt returns a Checker that accepts any integer or float value, and
@@ -143,14 +140,18 @@
type forceIntC struct{}
func (c forceIntC) Coerce(v interface{}, path []string) (interface{}, TypeOf( v).Kind( ) { ValueOf( v).Int( )), nil ValueOf( v).Float( )), nil TypeOf( v).Kind( ) { ParseInt( fmt.Sprintf( "%v", v), 0, 64) ValueOf( v).Int( )), nil ValueOf( v).Float( )), nil
error) {
- if v == nil {
- return nil, error_{"number", v, path}
- }
- switch reflect.
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32,
reflect.Int64:
- return int(reflect.
- case reflect.Float32, reflect.Float64:
- return int(reflect.
+ if v != nil {
+ switch reflect.
+ case reflect.String:
+ intValue, err := strconv.
+ if err == nil {
+ return int(intValue), nil
+ }
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32,
reflect.Int64:
+ return int(reflect.
+ case reflect.Float32, reflect.Float64:
+ return int(reflect.
+ }
}
return nil, error_{"number", v, path}
}
Index: schema/ schema_ test.go schema_ test.go' schema_ test.go 2013-09-27 01:50:46 +0000
=== modified file 'schema/
--- schema/
...