Merge lp:~themue/juju-core/041-revert-empty-strings-in-charm-config into lp:~go-bot/juju-core/trunk
Proposed by
Frank Mueller
Status: | Merged |
---|---|
Approved by: | Frank Mueller |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1725 |
Proposed branch: | lp:~themue/juju-core/041-revert-empty-strings-in-charm-config |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
136 lines (+29/-16) 4 files modified
charm/config.go (+5/-0) charm/config_test.go (+14/-13) state/apiserver/client/get_test.go (+6/-3) state/service_test.go (+4/-0) |
To merge this branch: | bzr merge lp:~themue/juju-core/041-revert-empty-strings-in-charm-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+182693@code.launchpad.net |
Commit message
charm: reverted empty string branch
Reverted the branch allowing empty string values
in charm configurations due incompatability with
the API.
Description of the change
charm: reverted empty string branch
Reverted the branch allowing empty string values
in charm configurations due incompatability with
the API.
To post a comment you must log in.
Reviewers: mp+182693_ code.launchpad. net,
Message:
Please take a look.
Description:
charm: reverted empty string branch
Reverted the branch allowing empty string values
in charm configurations due incompatability with
the API.
https:/ /code.launchpad .net/~themue/ juju-core/ 041-revert- empty-strings- in-charm- config/ +merge/ 182693
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/13349043/
Affected files: test.go /client/ get_test. go test.go
A [revision details]
M charm/config.go
M charm/config_
M state/apiserver
M state/service_
Index: [revision details] 20130828123627- r38fc3kmubd7nuc c
=== 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: charm/config.go ers[option. Type]; checker != nil { Coerce( value, nil); err != nil {
=== modified file 'charm/config.go'
--- charm/config.go 2013-08-26 15:39:55 +0000
+++ charm/config.go 2013-08-28 16:21:50 +0000
@@ -45,6 +45,8 @@
if checker := optionTypeCheck
if value, err = checker.
return nil, err
+ } else if value == "" {
+ value = nil
}
return value, nil
}
@@ -62,6 +64,9 @@
// returns an error if it cannot be parsed to the correct type. Empty
// string values are returned as nil.
func (option Option) parse(name, str string) (_ interface{}, err error) {
+ if str == "" {
+ return nil, nil
+ }
defer option.error(&err, name, str)
switch option.Type {
case "string":
Index: charm/config_ test.go config_ test.go' test.go 2013-08-26 15:39:55 +0000 test.go 2013-08-28 16:21:50 +0000 settings, gc.DeepEquals, charm.Settings{
=== modified file 'charm/
--- charm/config_
+++ charm/config_
@@ -112,7 +112,7 @@
c.Assert(
"title": "something valid",
"username": nil,
- "outlook": "",
+ "outlook": nil,
})
}
@@ -149,9 +149,9 @@ e-splines" : true, "outlook" : ""}, "outlook" : ""}, "outlook" : nil}, correctly- typed values are valid",
outlook: ""
skill-level: ""
agility- ratio: ""
reticulate- splines: ""`, string{ }, string{ "outlook" : ""}, "outlook" : ""},
"reticulat
},
}, {
- info: "empty string-typed values stay empty",
+ info: "empty string-typed values become nil",
input: charm.Settings{
- expect: charm.Settings{
+ expect: charm.Settings{
}, {
info: "almost-
input: charm.Settings{
@@ -279,14 +279,14 @@
key: "blah",
expect: settingsWithNils,
}, {
- info: "empty strings for non string options are not accepted",
+ info: "empty strings are considered nil",
yaml: `blah:
- key: "blah",
- err: `option "skill-level" expected int, got ""`,
+ key: "blah",
+ expect: settingsWithNils,
}, {
info: "appropriate strings are valid",
yaml: `blah:
@@ -331,13 +331,14 @@
input: map[string]
expect: charm.Settings{},
}, {
- info: "empty strings for string options are valid",
- input: map[string]
- expect: charm.Settings{
- }, {
- info: "empty strings for non string options are invalid",
- input...