Merge lp://staging/~fwereade/juju-core/config-3-state-unit-settings-rename into lp://staging/~juju/juju-core/trunk

Proposed by William Reade
Status: Merged
Approved by: William Reade
Approved revision: no longer in the source branch.
Merged at revision: 1272
Proposed branch: lp://staging/~fwereade/juju-core/config-3-state-unit-settings-rename
Merge into: lp://staging/~juju/juju-core/trunk
Prerequisite: lp://staging/~fwereade/juju-core/config-2-trivial-error-message-change
Diff against target: 0 lines
To merge this branch: bzr merge lp://staging/~fwereade/juju-core/config-3-state-unit-settings-rename
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+168577@code.staging.launchpad.net

Description of the change

state: Unit.ConfigSettings

Better name, better type; suitable changes propagated amongst clients.

https://codereview.appspot.com/10169044/

To post a comment you must log in.
Revision history for this message
William Reade (fwereade) wrote :
Download full text (8.7 KiB)

Reviewers: mp+168577_code.launchpad.net,

Message:
Please take a look.

Description:
state: Unit.ConfigSettings

Better name, better type; suitable changes propagated amongst clients.

https://code.launchpad.net/~fwereade/juju-core/config-3-state-unit-settings-rename/+merge/168577

Requires:
https://code.launchpad.net/~fwereade/juju-core/config-2-trivial-error-message-change/+merge/168576

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M state/unit.go
   M state/unit_test.go
   M worker/uniter/context.go
   M worker/uniter/context_test.go
   M worker/uniter/jujuc/config-get.go
   M worker/uniter/jujuc/context.go
   M worker/uniter/jujuc/util_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: <email address hidden>
+New revision: <email address hidden>

Index: state/unit.go
=== modified file 'state/unit.go'
--- state/unit.go 2013-06-10 20:37:49 +0000
+++ state/unit.go 2013-06-10 21:04:37 +0000
@@ -98,8 +98,11 @@
   return u.st.Service(u.doc.Service)
  }

-// ServiceConfig returns the contents of this unit's service configuration.
-func (u *Unit) ServiceConfig() (map[string]interface{}, error) {
+// ConfigSettings returns the complete set of service charm config settings
+// available to the unit. Unset values will be replaced with the default
+// value for the associated option, and may thus be nil when no default is
+// specified.
+func (u *Unit) ConfigSettings() (charm.Settings, error) {
   if u.doc.CharmURL == nil {
    return nil, fmt.Errorf("unit charm not set")
   }

Index: state/unit_test.go
=== modified file 'state/unit_test.go'
--- state/unit_test.go 2013-06-10 20:37:49 +0000
+++ state/unit_test.go 2013-06-10 21:04:37 +0000
@@ -45,30 +45,30 @@
   c.Assert(svc.Name(), Equals, s.unit.ServiceName())
  }

-func (s *UnitSuite) TestServiceConfigNeedsCharmURLSet(c *C) {
- _, err := s.unit.ServiceConfig()
+func (s *UnitSuite) TestConfigSettingsNeedCharmURLSet(c *C) {
+ _, err := s.unit.ConfigSettings()
   c.Assert(err, ErrorMatches, "unit charm not set")
  }

-func (s *UnitSuite) TestServiceConfigIncludesDefaults(c *C) {
+func (s *UnitSuite) TestConfigSettingsIncludeDefaults(c *C) {
   err := s.unit.SetCharmURL(s.charm.URL())
   c.Assert(err, IsNil)
- settings, err := s.unit.ServiceConfig()
+ settings, err := s.unit.ConfigSettings()
   c.Assert(err, IsNil)
- c.Assert(settings, DeepEquals, map[string]interface{}{"blog-title": "My
Title"})
+ c.Assert(settings, DeepEquals, charm.Settings{"blog-title": "My Title"})
  }

-func (s *UnitSuite) TestServiceConfigReflectsService(c *C) {
+func (s *UnitSuite) TestConfigSettingsReflectService(c *C) {
   err := s.service.SetConfig(map[string]string{"blog-title": "no title"})
   c.Assert(err, IsNil)
   err = s.unit.SetCharmURL(s.charm.URL())
   c.Assert(err, IsNil)
- settings, err := s.unit.ServiceConfig()
+ settings, err := s.unit.ConfigSettings()
   c.Assert(err, IsNil)
- c.Assert(settings, D...

Read more...

Revision history for this message
Tim Penhey (thumper) wrote :

On 2013/06/11 01:49:24, fwereade wrote:
> Please take a look.

LGTM - no other comments.

https://codereview.appspot.com/10169044/

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

LGTM

https://codereview.appspot.com/10169044/diff/1/worker/uniter/context.go
File worker/uniter/context.go (right):

https://codereview.appspot.com/10169044/diff/1/worker/uniter/context.go#newcode97
worker/uniter/context.go:97: for name, value := range ctx.configSettings
{
do we really need to make a copy?

https://codereview.appspot.com/10169044/

Revision history for this message
William Reade (fwereade) wrote :

*** Submitted:

state: Unit.ConfigSettings

Better name, better type; suitable changes propagated amongst clients.

R=thumper, wallyworld, rog
CC=
https://codereview.appspot.com/10169044

https://codereview.appspot.com/10169044/diff/1/worker/uniter/context.go
File worker/uniter/context.go (right):

https://codereview.appspot.com/10169044/diff/1/worker/uniter/context.go#newcode97
worker/uniter/context.go:97: for name, value := range ctx.configSettings
{
On 2013/06/11 12:10:04, rog wrote:
> do we really need to make a copy?

Better safe than sorry. I'm growing more paranoid in my old age.

https://codereview.appspot.com/10169044/

Preview Diff

Empty

Subscribers

People subscribed via source and target branches