Merge lp:~themue/juju-core/032-config-default-empty-string 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: | 1357 | ||||
Proposed branch: | lp:~themue/juju-core/032-config-default-empty-string | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
55 lines (+13/-1) 2 files modified
charm/config.go (+3/-1) charm/config_test.go (+10/-0) |
||||
To merge this branch: | bzr merge lp:~themue/juju-core/032-config-default-empty-string | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+171779@code.launchpad.net |
Commit message
charm: allow empty string as default value
The current solution is incompatible to pyjuju,
where empty strings as default values are allowed.
Added this as an exceptional case to the charm
config.
Description of the change
charm: allow empty string as default value
The current solution is incompatible to pyjuju,
where empty strings as default values are allowed.
Added this as an exceptional case to the charm
config.
To post a comment you must log in.
Reviewers: mp+171779_ code.launchpad. net,
Message:
Please take a look.
Description:
charm: allow empty string as default value
The current solution is incompatible to pyjuju,
where empty strings as default values are allowed.
Added this as an exceptional case to the charm
config.
https:/ /code.launchpad .net/~themue/ juju-core/ 032-config- default- empty-string/ +merge/ 171779
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/10682043/
Affected files: test.go
A [revision details]
M charm/config.go
M charm/config_
Index: [revision details] 20130627084404- bq6fxhiknqub7hn a
=== 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 validate( name, def); err != nil { validate( name, def); err != nil { Options[ name] = option
=== modified file 'charm/config.go'
--- charm/config.go 2013-06-11 14:55:46 +0000
+++ charm/config.go 2013-06-27 11:50:08 +0000
@@ -110,10 +110,13 @@
default:
return nil, fmt.Errorf("invalid config: option %q has unknown type %q",
name, option.Type)
}
- def := option.Default
- if option.Default, err = option.
- option.error(&err, name, def)
- return nil, fmt.Errorf("invalid config default: %v", err)
+ if !(option.Type == "string" && option.Default == "") {
+ // Empty default string is an exceptional case due to compatability
reasons.
+ def := option.Default
+ if option.Default, err = option.
+ option.error(&err, name, def)
+ return nil, fmt.Errorf("invalid config default: %v", err)
+ }
}
config.
}
Index: charm/config_ test.go config_ test.go' test.go 2013-06-17 13:12:56 +0000 test.go 2013-06-27 11:50:08 +0000 ings(c *C) { s.config. DefaultSettings (), DeepEquals, charm.Settings{ ngs(c *C) { FilterSettings( charm.Settings{
=== modified file 'charm/
--- charm/config_
+++ charm/config_
@@ -26,6 +26,9 @@
default: My Title
description: A descriptive title used for the service.
type: string
+ subtitle:
+ default: ""
+ description: An optional subtitle used for the service.
outlook:
description: No default outlook.
# type defaults to string in python
@@ -53,6 +56,11 @@
Description: "A descriptive title used for the service.",
Type: "string",
},
+ "subtitle": {
+ Default: "",
+ Description: "An optional subtitle used for the service.",
+ Type: "string",
+ },
"username": {
Default: "admin001",
Description: "The name of the initial account (given admin
permissions).",
@@ -80,6 +88,7 @@
func (s *ConfigSuite) TestDefaultSett
c.Assert(
"title": "My Title",
+ "subtitle": "",
"username": "admin001",
"outlook": nil,
"skill-level": nil,
@@ -91,6 +100,7 @@
func (s *ConfigSuite) TestFilterSetti
settings := s.config.
"title": "something valid",
+ "subtitle": "",
"username": nil,
"unknown": "whatever",
"outlook":...