Merge lp:~axwalk/juju-core/manual-auto-generate-storageauthkey 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: 2273
Proposed branch: lp:~axwalk/juju-core/manual-auto-generate-storageauthkey
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 201 lines (+66/-19)
6 files modified
cmd/jujud/machine_test.go (+1/-1)
provider/null/config_test.go (+9/-9)
provider/null/environ_test.go (+3/-3)
provider/null/export_test.go (+8/-0)
provider/null/provider.go (+13/-6)
provider/null/provider_test.go (+32/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/manual-auto-generate-storageauthkey
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+203693@code.launchpad.net

Commit message

manual: generate storage-auth-key in Prepare

https://codereview.appspot.com/58210043/

Description of the change

manual: generate storage-auth-key in Prepare

https://codereview.appspot.com/58210043/

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

Reviewers: mp+203693_code.launchpad.net,

Message:
Please take a look.

Description:
manual: generate storage-auth-key in Prepare

https://code.launchpad.net/~axwalk/juju-core/manual-auto-generate-storageauthkey/+merge/203693

(do not edit description out of merge proposal)

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

Affected files (+68, -19 lines):
   A [revision details]
   M cmd/jujud/machine_test.go
   M provider/null/config_test.go
   M provider/null/environ_test.go
   A provider/null/export_test.go
   M provider/null/provider.go
   A provider/null/provider_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-20140129060438-5kse5gkrbnxkwu27
+New revision: <email address hidden>

Index: cmd/jujud/machine_test.go
=== modified file 'cmd/jujud/machine_test.go'
--- cmd/jujud/machine_test.go 2014-01-29 04:59:18 +0000
+++ cmd/jujud/machine_test.go 2014-01-29 10:08:01 +0000
@@ -31,8 +31,8 @@

charmtesting "launchpad.net/juju-core/state/apiserver/charmrevisionupdater/testing"
   statetesting "launchpad.net/juju-core/state/testing"
   "launchpad.net/juju-core/state/watcher"
+ "launchpad.net/juju-core/testing"
   coretesting "launchpad.net/juju-core/testing"
- "launchpad.net/juju-core/testing"
   jc "launchpad.net/juju-core/testing/checkers"
   "launchpad.net/juju-core/testing/testbase"
   "launchpad.net/juju-core/tools"

Index: provider/null/config_test.go
=== modified file 'provider/null/config_test.go'
--- provider/null/config_test.go 2013-12-23 06:06:40 +0000
+++ provider/null/config_test.go 2014-01-29 10:08:01 +0000
@@ -21,7 +21,7 @@

  var _ = gc.Suite(&configSuite{})

-func minimalConfigValues() map[string]interface{} {
+func MinimalConfigValues() map[string]interface{} {
   return map[string]interface{}{
    "name": "test",
    "type": provider.Null,
@@ -34,8 +34,8 @@
   }
  }

-func minimalConfig(c *gc.C) *config.Config {
- minimal := minimalConfigValues()
+func MinimalConfig(c *gc.C) *config.Config {
+ minimal := MinimalConfigValues()
   testConfig, err := config.New(config.UseDefaults, minimal)
   c.Assert(err, gc.IsNil)
   return testConfig
@@ -50,7 +50,7 @@
  }

  func (s *configSuite) TestValidateConfig(c *gc.C) {
- testConfig := minimalConfig(c)
+ testConfig := MinimalConfig(c)
   testConfig, err :=
testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})
   c.Assert(err, gc.IsNil)
   _, err = nullProvider{}.Validate(testConfig, nil)
@@ -61,7 +61,7 @@
   _, err = nullProvider{}.Validate(testConfig, nil)
   c.Assert(err, gc.ErrorMatches, "storage-auth-key: expected string, got
nothing")

- testConfig = minimalConfig(c)
+ testConfig = MinimalConfig(c)
   valid, err := nullProvider{}.Validate(testConfig, nil)
   c.Assert(err, gc.IsNil)

@@ -73,7 +73,7 @@
  }

  func (s *configSuite) TestConfigMutability(c *gc.C) {
- testConfig := minimalConfig(c)
+ testConfig := MinimalConfig(c)
   valid, err := nullProvider{}.Validate(testConfig, nil)
   c.Assert(err, gc.IsNil)
   unknownAttrs := vali...

Read more...

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

LGTM. I though we're renaming the null provider to manual or I'm
mistaken?

https://codereview.appspot.com/58210043/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

On 2014/01/29 10:27:22, dimitern wrote:
> LGTM. I though we're renaming the null provider to manual or I'm
mistaken?

Thanks. Yes, we are (https://codereview.appspot.com/53040046/)

Should've done a prereq, really. Oh well.

https://codereview.appspot.com/58210043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/jujud/machine_test.go'
2--- cmd/jujud/machine_test.go 2014-01-29 04:59:18 +0000
3+++ cmd/jujud/machine_test.go 2014-01-29 10:09:08 +0000
4@@ -31,8 +31,8 @@
5 charmtesting "launchpad.net/juju-core/state/apiserver/charmrevisionupdater/testing"
6 statetesting "launchpad.net/juju-core/state/testing"
7 "launchpad.net/juju-core/state/watcher"
8+ "launchpad.net/juju-core/testing"
9 coretesting "launchpad.net/juju-core/testing"
10- "launchpad.net/juju-core/testing"
11 jc "launchpad.net/juju-core/testing/checkers"
12 "launchpad.net/juju-core/testing/testbase"
13 "launchpad.net/juju-core/tools"
14
15=== modified file 'provider/null/config_test.go'
16--- provider/null/config_test.go 2013-12-23 06:06:40 +0000
17+++ provider/null/config_test.go 2014-01-29 10:09:08 +0000
18@@ -21,7 +21,7 @@
19
20 var _ = gc.Suite(&configSuite{})
21
22-func minimalConfigValues() map[string]interface{} {
23+func MinimalConfigValues() map[string]interface{} {
24 return map[string]interface{}{
25 "name": "test",
26 "type": provider.Null,
27@@ -34,8 +34,8 @@
28 }
29 }
30
31-func minimalConfig(c *gc.C) *config.Config {
32- minimal := minimalConfigValues()
33+func MinimalConfig(c *gc.C) *config.Config {
34+ minimal := MinimalConfigValues()
35 testConfig, err := config.New(config.UseDefaults, minimal)
36 c.Assert(err, gc.IsNil)
37 return testConfig
38@@ -50,7 +50,7 @@
39 }
40
41 func (s *configSuite) TestValidateConfig(c *gc.C) {
42- testConfig := minimalConfig(c)
43+ testConfig := MinimalConfig(c)
44 testConfig, err := testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})
45 c.Assert(err, gc.IsNil)
46 _, err = nullProvider{}.Validate(testConfig, nil)
47@@ -61,7 +61,7 @@
48 _, err = nullProvider{}.Validate(testConfig, nil)
49 c.Assert(err, gc.ErrorMatches, "storage-auth-key: expected string, got nothing")
50
51- testConfig = minimalConfig(c)
52+ testConfig = MinimalConfig(c)
53 valid, err := nullProvider{}.Validate(testConfig, nil)
54 c.Assert(err, gc.IsNil)
55
56@@ -73,7 +73,7 @@
57 }
58
59 func (s *configSuite) TestConfigMutability(c *gc.C) {
60- testConfig := minimalConfig(c)
61+ testConfig := MinimalConfig(c)
62 valid, err := nullProvider{}.Validate(testConfig, nil)
63 c.Assert(err, gc.IsNil)
64 unknownAttrs := valid.UnknownAttrs()
65@@ -88,7 +88,7 @@
66 "storage-listen-ip": "10.0.0.123",
67 "storage-port": int64(1234),
68 } {
69- testConfig = minimalConfig(c)
70+ testConfig = MinimalConfig(c)
71 testConfig, err = testConfig.Apply(map[string]interface{}{k: v})
72 c.Assert(err, gc.IsNil)
73 _, err := nullProvider{}.Validate(testConfig, oldConfig)
74@@ -99,7 +99,7 @@
75 }
76
77 func (s *configSuite) TestBootstrapHostUser(c *gc.C) {
78- values := minimalConfigValues()
79+ values := MinimalConfigValues()
80 testConfig := getEnvironConfig(c, values)
81 c.Assert(testConfig.bootstrapHost(), gc.Equals, "hostname")
82 c.Assert(testConfig.bootstrapUser(), gc.Equals, "")
83@@ -111,7 +111,7 @@
84 }
85
86 func (s *configSuite) TestStorageParams(c *gc.C) {
87- values := minimalConfigValues()
88+ values := MinimalConfigValues()
89 testConfig := getEnvironConfig(c, values)
90 c.Assert(testConfig.storageAddr(), gc.Equals, "hostname:8040")
91 c.Assert(testConfig.storageListenAddr(), gc.Equals, ":8040")
92
93=== modified file 'provider/null/environ_test.go'
94--- provider/null/environ_test.go 2014-01-08 05:49:24 +0000
95+++ provider/null/environ_test.go 2014-01-29 10:09:08 +0000
96@@ -29,15 +29,15 @@
97 var _ = gc.Suite(&environSuite{})
98
99 func (s *environSuite) SetUpTest(c *gc.C) {
100- envConfig := getEnvironConfig(c, minimalConfigValues())
101+ envConfig := getEnvironConfig(c, MinimalConfigValues())
102 s.env = &nullEnviron{cfg: envConfig}
103 }
104
105 func (s *environSuite) TestSetConfig(c *gc.C) {
106- err := s.env.SetConfig(minimalConfig(c))
107+ err := s.env.SetConfig(MinimalConfig(c))
108 c.Assert(err, gc.IsNil)
109
110- testConfig := minimalConfig(c)
111+ testConfig := MinimalConfig(c)
112 testConfig, err = testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})
113 c.Assert(err, gc.IsNil)
114 err = s.env.SetConfig(testConfig)
115
116=== added file 'provider/null/export_test.go'
117--- provider/null/export_test.go 1970-01-01 00:00:00 +0000
118+++ provider/null/export_test.go 2014-01-29 10:09:08 +0000
119@@ -0,0 +1,8 @@
120+// Copyright 2014 Canonical Ltd.
121+// Licensed under the AGPLv3, see LICENCE file for details.
122+
123+package null
124+
125+var (
126+ ProviderInstance = nullProvider{}
127+)
128
129=== modified file 'provider/null/provider.go'
130--- provider/null/provider.go 2013-10-15 05:11:29 +0000
131+++ provider/null/provider.go 2014-01-29 10:09:08 +0000
132@@ -22,7 +22,18 @@
133 var errNoBootstrapHost = errors.New("bootstrap-host must be specified")
134
135 func (p nullProvider) Prepare(cfg *config.Config) (environs.Environ, error) {
136- // TODO(rog) 2013-10-07 generate storage-auth-key if not set.
137+ if _, ok := cfg.UnknownAttrs()["storage-auth-key"].(string); !ok {
138+ uuid, err := utils.NewUUID()
139+ if err != nil {
140+ return nil, err
141+ }
142+ cfg, err = cfg.Apply(map[string]interface{}{
143+ "storage-auth-key": uuid.String(),
144+ })
145+ if err != nil {
146+ return nil, err
147+ }
148+ }
149 return p.Open(cfg)
150 }
151
152@@ -112,11 +123,7 @@
153 # bootstrap machine's Juju storage server will listen
154 # on. It defaults to ` + fmt.Sprint(defaultStoragePort) + `
155 # storage-port: ` + fmt.Sprint(defaultStoragePort) + `
156-
157- # storage-auth-key holds the key used to authenticate
158- # to the storage servers. It will become unnecessary to
159- # give this option.
160- storage-auth-key: {{rand}}
161+
162
163 `[1:]
164 }
165
166=== added file 'provider/null/provider_test.go'
167--- provider/null/provider_test.go 1970-01-01 00:00:00 +0000
168+++ provider/null/provider_test.go 2014-01-29 10:09:08 +0000
169@@ -0,0 +1,32 @@
170+// Copyright 2014 Canonical Ltd.
171+// Licensed under the AGPLv3, see LICENCE file for details.
172+
173+package null_test
174+
175+import (
176+ gc "launchpad.net/gocheck"
177+
178+ "launchpad.net/juju-core/environs/config"
179+ "launchpad.net/juju-core/provider/null"
180+ jc "launchpad.net/juju-core/testing/checkers"
181+ "launchpad.net/juju-core/testing/testbase"
182+ "launchpad.net/juju-core/utils"
183+)
184+
185+type providerSuite struct {
186+ testbase.LoggingSuite
187+}
188+
189+var _ = gc.Suite(&providerSuite{})
190+
191+func (s *providerSuite) TestPrepare(c *gc.C) {
192+ minimal := null.MinimalConfigValues()
193+ delete(minimal, "storage-auth-key")
194+ testConfig, err := config.New(config.UseDefaults, minimal)
195+ c.Assert(err, gc.IsNil)
196+ env, err := null.ProviderInstance.Prepare(testConfig)
197+ c.Assert(err, gc.IsNil)
198+ cfg := env.Config()
199+ key, _ := cfg.UnknownAttrs()["storage-auth-key"].(string)
200+ c.Assert(key, jc.Satisfies, utils.IsValidUUIDString)
201+}

Subscribers

People subscribed via source and target branches

to status/vote changes: