Merge lp:~axwalk/juju-core/config-defaults into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 2353
Proposed branch: lp:~axwalk/juju-core/config-defaults
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 39 lines (+10/-1)
2 files modified
environs/config/config.go (+6/-1)
environs/config/config_test.go (+4/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/config-defaults
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+207609@code.launchpad.net

Commit message

environs/config: fix optional values/defaults

We have config values which are optional for
backwards compatibility. In some cases these
should take on a different value to what the
default for a new config is. The way the defaults
map is currently constructed means that the
backwards-compatibility values always overwrite
the defaults.

https://codereview.appspot.com/66920043/

Description of the change

environs/config: fix optional values/defaults

We have config values which are optional for
backwards compatibility. In some cases these
should take on a different value to what the
default for a new config is. The way the defaults
map is currently constructed means that the
backwards-compatibility values always overwrite
the defaults.

https://codereview.appspot.com/66920043/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+207609_code.launchpad.net,

Message:
Please take a look.

Description:
environs/config: fix optional values/defaults

We have config values which are optional for
backwards compatibility. In some cases these
should take on a different value to what the
default for a new config is. The way the defaults
map is currently constructed means that the
backwards-compatibility values always overwrite
the defaults.

https://code.launchpad.net/~axwalk/juju-core/config-defaults/+merge/207609

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/66920043/

Affected files (+12, -1 lines):
   A [revision details]
   M environs/config/config.go
   M environs/config/config_test.go

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: tarmac-20140220160904-67ajnt8y3n3jd73c
+New revision: <email address hidden>

Index: environs/config/config.go
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2014-02-12 04:54:19 +0000
+++ environs/config/config.go 2014-02-21 10:00:22 +0000
@@ -742,6 +742,9 @@

  var defaults = allDefaults()

+// allDefaults returns a schema.Defaults that contains
+// defaults to be used when creating a new config with
+// UseDefaults.
  func allDefaults() schema.Defaults {
   d := schema.Defaults{
    "default-series": DefaultSeries,
@@ -756,7 +759,9 @@
    "bootstrap-addresses-delay": DefaultBootstrapSSHAddressesDelay,
   }
   for attr, val := range alwaysOptional {
- d[attr] = val
+ if _, ok := d[attr]; !ok {
+ d[attr] = val
+ }
   }
   return d
  }

Index: environs/config/config_test.go
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2014-02-12 04:54:19 +0000
+++ environs/config/config_test.go 2014-02-21 10:00:22 +0000
@@ -1100,6 +1100,10 @@
   about: "Cannot change the syslog-port from implicit-default to different
value",
   new: testing.Attrs{"syslog-port": 42},
   err: `cannot change syslog-port from 514 to 42`,
+}, {
+ about: "Cannot change the bootstrap-timeout from implicit-default to
different value",
+ new: testing.Attrs{"bootstrap-timeout": 5},
+ err: `cannot change bootstrap-timeout from 600 to 5`,
  }}

  func (*ConfigSuite) TestValidateChange(c *gc.C) {

Revision history for this message
Ian Booth (wallyworld) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/config/config.go'
2--- environs/config/config.go 2014-02-12 04:54:19 +0000
3+++ environs/config/config.go 2014-02-21 10:06:08 +0000
4@@ -742,6 +742,9 @@
5
6 var defaults = allDefaults()
7
8+// allDefaults returns a schema.Defaults that contains
9+// defaults to be used when creating a new config with
10+// UseDefaults.
11 func allDefaults() schema.Defaults {
12 d := schema.Defaults{
13 "default-series": DefaultSeries,
14@@ -756,7 +759,9 @@
15 "bootstrap-addresses-delay": DefaultBootstrapSSHAddressesDelay,
16 }
17 for attr, val := range alwaysOptional {
18- d[attr] = val
19+ if _, ok := d[attr]; !ok {
20+ d[attr] = val
21+ }
22 }
23 return d
24 }
25
26=== modified file 'environs/config/config_test.go'
27--- environs/config/config_test.go 2014-02-12 04:54:19 +0000
28+++ environs/config/config_test.go 2014-02-21 10:06:08 +0000
29@@ -1100,6 +1100,10 @@
30 about: "Cannot change the syslog-port from implicit-default to different value",
31 new: testing.Attrs{"syslog-port": 42},
32 err: `cannot change syslog-port from 514 to 42`,
33+}, {
34+ about: "Cannot change the bootstrap-timeout from implicit-default to different value",
35+ new: testing.Attrs{"bootstrap-timeout": 5},
36+ err: `cannot change bootstrap-timeout from 600 to 5`,
37 }}
38
39 func (*ConfigSuite) TestValidateChange(c *gc.C) {

Subscribers

People subscribed via source and target branches

to status/vote changes: