Merge lp://staging/~themue/juju-core/037-empty-strings-in-charm-config into lp://staging/~go-bot/juju-core/trunk
Proposed by
Frank Mueller
Status: | Work in progress |
---|---|
Proposed branch: | lp://staging/~themue/juju-core/037-empty-strings-in-charm-config |
Merge into: | lp://staging/~go-bot/juju-core/trunk |
Prerequisite: | lp://staging/~themue/juju-core/036-set-default |
Diff against target: |
149 lines (+23/-18) 5 files modified
charm/config.go (+2/-2) charm/config_test.go (+12/-9) cmd/juju/config_test.go (+7/-0) state/service_test.go (+0/-4) state/statecmd/config_test.go (+2/-3) |
To merge this branch: | bzr merge lp://staging/~themue/juju-core/037-empty-strings-in-charm-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+178318@code.staging.launchpad.net |
Description of the change
charm: allow empty strings as config values
This is the second CL for lp:1194945. It allows empty strings
as valid values for config options with the type string. Merging
should be done after none has signalled a compatibility problem
as answer to the query mail on the mailing list.
To post a comment you must log in.
Unmerged revisions
- 1572. By Frank Mueller
-
charm: allowing empty strings as valid config value for string types
- 1571. By Frank Mueller
-
cmd/set: corrected the reset of an invalid change to be exact like before
- 1570. By Frank Mueller
-
cmd/set: merged trunk
- 1569. By Frank Mueller
-
cmd/set: removed setting to empty string until clearance
- 1568. By Frank Mueller
-
cmd/set: add option --default to set to default value
Reviewers: mp+178318_ code.launchpad. net,
Message:
Please take a look.
Description:
charm: allow empty strings as config values
This is the second CL for lp:1194945. It allows empty strings
as valid values for config options with the type string. Merging
should be done after none has signalled a compatibility problem
as answer to the query mail on the mailing list.
https:/ /code.launchpad .net/~themue/ juju-core/ 037-empty- strings- in-charm- config/ +merge/ 178318
Requires: /code.launchpad .net/~themue/ juju-core/ 036-set- default/ +merge/ 178279
https:/
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/12343045/
Affected files: test.go config_ test.go test.go config_ test.go
A [revision details]
M charm/config.go
M charm/config_
M cmd/juju/
M state/service_
M state/statecmd/
Index: [revision details]
=== 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: <email address hidden>
+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-02 12:16:22 +0000
+++ charm/config.go 2013-08-02 14:54:09 +0000
@@ -45,7 +45,7 @@
if checker := optionTypeCheck
if value, err = checker.
return nil, err
- } else if value == "" {
+ } else if option.Type != "string" && value == "" {
value = nil
}
return value, nil
@@ -64,7 +64,7 @@
// 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 == "" {
+ if option.Type != "string" && str == "" {
return nil, nil
}
defer option.error(&err, name, str)
Index: charm/config_ test.go config_ test.go' test.go 2013-07-19 14:49:06 +0000 test.go 2013-08-02 14:54:09 +0000 settings, DeepEquals, charm.Settings{
=== modified file 'charm/
--- charm/config_
+++ charm/config_
@@ -112,7 +112,7 @@
c.Assert(
"title": "something valid",
"username": nil,
- "outlook": nil,
+ "outlook": "",
})
}
@@ -149,10 +149,6 @@ e-splines" : true, "outlook" : ""}, "outlook" : nil}, correctly- typed values are valid", splines" : nil,
"reticulat
},
}, {
- info: "empty string-typed values become nil",
- input: charm.Settings{
- expect: charm.Settings{
- }, {
info: "almost-
input: charm.Settings{
"skill-level": 123,
@@ -201,6 +197,13 @@
"reticulate-
}
+var settingsWithEmp tyString = charm.Settings{ splines" : nil,
outlook: ""
+ "outlook": "",
+ "skill-level": nil,
+ "agility-ratio": nil,
+ "reticulate-
+}
+
var settingsWithValues = charm.Settings{
"outlook": "whatever",
"skill-level": int64(123),
@@ -279,14 +282,14 @@
key: "blah",
expect: settingsWithNils,
}, {
- info: "empty strings are considered nil",
+ info: "empty strings are considered nil for non-string types",
yaml: `blah:
...