Merge lp:~mattyw/juju-core/1199432 into lp:~go-bot/juju-core/trunk
Proposed by
Matthew Williams
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | William Reade | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1498 | ||||
Proposed branch: | lp:~mattyw/juju-core/1199432 | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
29 lines (+11/-0) 2 files modified
charm/config.go (+3/-0) charm/config_test.go (+8/-0) |
||||
To merge this branch: | bzr merge lp:~mattyw/juju-core/1199432 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+175856@code.launchpad.net |
Commit message
Bug fix for lp:1199432
Currently an empty config supplied to charm.ReadConfig causes a panic, it would be better to return an error. lp:1199432
Description of the change
Bug fix for lp:1199432
Currently an empty config supplied to charm.ReadConfig causes a panic, it would be better to return an error. lp:1199432
To post a comment you must log in.
Reviewers: mp+175856_ code.launchpad. net,
Message:
Please take a look.
Description:
Bug fix for lp:1199432
Currently an empty config supplied to charm.ReadConfig causes a panic,
it would be better to return an error. lp:1199432
https:/ /code.launchpad .net/~mattyw/ juju-core/ 1199432/ +merge/ 175856
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/11542046/
Affected files: test.go
A [revision details]
M charm/config.go
M charm/config_
Index: [revision details] 20130719095358- 4z29gui2k03po34 w
=== 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 Unmarshal( data, &config); err != nil {
=== modified file 'charm/config.go'
--- charm/config.go 2013-07-09 10:32:23 +0000
+++ charm/config.go 2013-07-19 14:49:06 +0000
@@ -102,6 +102,9 @@
if err := goyaml.
return nil, err
}
+ if config == nil {
+ return nil, fmt.Errorf("invalid config: empty configuration")
+ }
for name, option := range config.Options {
switch option.Type {
case "string", "int", "float", "boolean":
Index: charm/config_ test.go config_ test.go' test.go 2013-07-09 10:32:23 +0000 test.go 2013-07-19 14:49:06 +0000 ror("float" , "123", "123") ror("int" , "true", "true") ReturnsError( c *C) { g(bytes. NewBuffer( []byte( config) ))
=== modified file 'charm/
--- charm/config_
+++ charm/config_
@@ -403,3 +403,11 @@
assertTypeEr
assertTypeEr
}
+
+// When an empty config is supplied an error should be returned
+func (s *ConfigSuite) TestEmptyConfig
+ config := ""
+ result, err := charm.ReadConfi
+ c.Assert(result, IsNil)
+ c.Assert(err, ErrorMatches, "invalid config: empty configuration")
+}