Merge lp:~thumper/juju-core/local-config-tilde into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1640
Proposed branch: lp:~thumper/juju-core/local-config-tilde
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 39 lines (+16/-1)
2 files modified
environs/local/config_test.go (+14/-0)
environs/local/environprovider.go (+2/-1)
To merge this branch: bzr merge lp:~thumper/juju-core/local-config-tilde
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+179454@code.launchpad.net

Commit message

Fix the ~/ expansion in local provider config.

https://codereview.appspot.com/12491046/

Description of the change

Fix the ~/ expansion in local provider config.

https://codereview.appspot.com/12491046/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Reviewers: mp+179454_code.launchpad.net,

Message:
Please take a look.

Description:
Fix the ~/ expansion in local provider config.

https://code.launchpad.net/~thumper/juju-core/local-config-tilde/+merge/179454

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M environs/local/config_test.go
   M environs/local/environprovider.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-20130809101629-8zemj78995x4068u
+New revision: <email address hidden>

Index: environs/local/config_test.go
=== modified file 'environs/local/config_test.go'
--- environs/local/config_test.go 2013-07-17 02:34:39 +0000
+++ environs/local/config_test.go 2013-08-09 14:30:22 +0000
@@ -78,6 +78,20 @@
   c.Assert(unknownAttrs["root-dir"], gc.Equals, root)
  }

+func (s *configSuite) TestValidateConfigWithTildeInRootDir(c *gc.C) {
+ values := minimalConfigValues()
+ values["root-dir"] = "~/.juju/foo"
+ testConfig, err := config.New(values)
+ c.Assert(err, gc.IsNil)
+
+ valid, err := local.Provider.Validate(testConfig, nil)
+ c.Assert(err, gc.IsNil)
+
+ expectedRootDir := filepath.Join(os.Getenv("HOME"), ".juju", "foo")
+ unknownAttrs := valid.UnknownAttrs()
+ c.Assert(unknownAttrs["root-dir"], gc.Equals, expectedRootDir)
+}
+
  func (s *configSuite) TestNamespace(c *gc.C) {
   testConfig := minimalConfig(c)
   c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")

Index: environs/local/environprovider.go
=== modified file 'environs/local/environprovider.go'
--- environs/local/environprovider.go 2013-08-09 06:42:05 +0000
+++ environs/local/environprovider.go 2013-08-09 14:30:22 +0000
@@ -88,8 +88,9 @@
   dir := utils.NormalizePath(localConfig.rootDir())
   if dir == "." {
    dir = config.JujuHomePath(cfg.Name())
- localConfig.attrs["root-dir"] = dir
   }
+ // Always assign the normalized path.
+ localConfig.attrs["root-dir"] = dir

   // Apply the coerced unknown values back into the config.
   return cfg.Apply(localConfig.attrs)

Revision history for this message
John A Meinel (jameinel) wrote :
Revision history for this message
William Reade (fwereade) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/local/config_test.go'
2--- environs/local/config_test.go 2013-07-17 02:34:39 +0000
3+++ environs/local/config_test.go 2013-08-09 14:32:40 +0000
4@@ -78,6 +78,20 @@
5 c.Assert(unknownAttrs["root-dir"], gc.Equals, root)
6 }
7
8+func (s *configSuite) TestValidateConfigWithTildeInRootDir(c *gc.C) {
9+ values := minimalConfigValues()
10+ values["root-dir"] = "~/.juju/foo"
11+ testConfig, err := config.New(values)
12+ c.Assert(err, gc.IsNil)
13+
14+ valid, err := local.Provider.Validate(testConfig, nil)
15+ c.Assert(err, gc.IsNil)
16+
17+ expectedRootDir := filepath.Join(os.Getenv("HOME"), ".juju", "foo")
18+ unknownAttrs := valid.UnknownAttrs()
19+ c.Assert(unknownAttrs["root-dir"], gc.Equals, expectedRootDir)
20+}
21+
22 func (s *configSuite) TestNamespace(c *gc.C) {
23 testConfig := minimalConfig(c)
24 c.Assert(local.ConfigNamespace(testConfig), gc.Equals, "tester-test")
25
26=== modified file 'environs/local/environprovider.go'
27--- environs/local/environprovider.go 2013-08-09 06:42:05 +0000
28+++ environs/local/environprovider.go 2013-08-09 14:32:40 +0000
29@@ -88,8 +88,9 @@
30 dir := utils.NormalizePath(localConfig.rootDir())
31 if dir == "." {
32 dir = config.JujuHomePath(cfg.Name())
33- localConfig.attrs["root-dir"] = dir
34 }
35+ // Always assign the normalized path.
36+ localConfig.attrs["root-dir"] = dir
37
38 // Apply the coerced unknown values back into the config.
39 return cfg.Apply(localConfig.attrs)

Subscribers

People subscribed via source and target branches

to status/vote changes: