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
=== 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:09:08 +0000
@@ -31,8 +31,8 @@
31 charmtesting "launchpad.net/juju-core/state/apiserver/charmrevisionupdater/testing"31 charmtesting "launchpad.net/juju-core/state/apiserver/charmrevisionupdater/testing"
32 statetesting "launchpad.net/juju-core/state/testing"32 statetesting "launchpad.net/juju-core/state/testing"
33 "launchpad.net/juju-core/state/watcher"33 "launchpad.net/juju-core/state/watcher"
34 "launchpad.net/juju-core/testing"
34 coretesting "launchpad.net/juju-core/testing"35 coretesting "launchpad.net/juju-core/testing"
35 "launchpad.net/juju-core/testing"
36 jc "launchpad.net/juju-core/testing/checkers"36 jc "launchpad.net/juju-core/testing/checkers"
37 "launchpad.net/juju-core/testing/testbase"37 "launchpad.net/juju-core/testing/testbase"
38 "launchpad.net/juju-core/tools"38 "launchpad.net/juju-core/tools"
3939
=== 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:09:08 +0000
@@ -21,7 +21,7 @@
2121
22var _ = gc.Suite(&configSuite{})22var _ = gc.Suite(&configSuite{})
2323
24func minimalConfigValues() map[string]interface{} {24func MinimalConfigValues() map[string]interface{} {
25 return map[string]interface{}{25 return map[string]interface{}{
26 "name": "test",26 "name": "test",
27 "type": provider.Null,27 "type": provider.Null,
@@ -34,8 +34,8 @@
34 }34 }
35}35}
3636
37func minimalConfig(c *gc.C) *config.Config {37func MinimalConfig(c *gc.C) *config.Config {
38 minimal := minimalConfigValues()38 minimal := MinimalConfigValues()
39 testConfig, err := config.New(config.UseDefaults, minimal)39 testConfig, err := config.New(config.UseDefaults, minimal)
40 c.Assert(err, gc.IsNil)40 c.Assert(err, gc.IsNil)
41 return testConfig41 return testConfig
@@ -50,7 +50,7 @@
50}50}
5151
52func (s *configSuite) TestValidateConfig(c *gc.C) {52func (s *configSuite) TestValidateConfig(c *gc.C) {
53 testConfig := minimalConfig(c)53 testConfig := MinimalConfig(c)
54 testConfig, err := testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})54 testConfig, err := testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})
55 c.Assert(err, gc.IsNil)55 c.Assert(err, gc.IsNil)
56 _, err = nullProvider{}.Validate(testConfig, nil)56 _, err = nullProvider{}.Validate(testConfig, nil)
@@ -61,7 +61,7 @@
61 _, err = nullProvider{}.Validate(testConfig, nil)61 _, err = nullProvider{}.Validate(testConfig, nil)
62 c.Assert(err, gc.ErrorMatches, "storage-auth-key: expected string, got nothing")62 c.Assert(err, gc.ErrorMatches, "storage-auth-key: expected string, got nothing")
6363
64 testConfig = minimalConfig(c)64 testConfig = MinimalConfig(c)
65 valid, err := nullProvider{}.Validate(testConfig, nil)65 valid, err := nullProvider{}.Validate(testConfig, nil)
66 c.Assert(err, gc.IsNil)66 c.Assert(err, gc.IsNil)
6767
@@ -73,7 +73,7 @@
73}73}
7474
75func (s *configSuite) TestConfigMutability(c *gc.C) {75func (s *configSuite) TestConfigMutability(c *gc.C) {
76 testConfig := minimalConfig(c)76 testConfig := MinimalConfig(c)
77 valid, err := nullProvider{}.Validate(testConfig, nil)77 valid, err := nullProvider{}.Validate(testConfig, nil)
78 c.Assert(err, gc.IsNil)78 c.Assert(err, gc.IsNil)
79 unknownAttrs := valid.UnknownAttrs()79 unknownAttrs := valid.UnknownAttrs()
@@ -88,7 +88,7 @@
88 "storage-listen-ip": "10.0.0.123",88 "storage-listen-ip": "10.0.0.123",
89 "storage-port": int64(1234),89 "storage-port": int64(1234),
90 } {90 } {
91 testConfig = minimalConfig(c)91 testConfig = MinimalConfig(c)
92 testConfig, err = testConfig.Apply(map[string]interface{}{k: v})92 testConfig, err = testConfig.Apply(map[string]interface{}{k: v})
93 c.Assert(err, gc.IsNil)93 c.Assert(err, gc.IsNil)
94 _, err := nullProvider{}.Validate(testConfig, oldConfig)94 _, err := nullProvider{}.Validate(testConfig, oldConfig)
@@ -99,7 +99,7 @@
99}99}
100100
101func (s *configSuite) TestBootstrapHostUser(c *gc.C) {101func (s *configSuite) TestBootstrapHostUser(c *gc.C) {
102 values := minimalConfigValues()102 values := MinimalConfigValues()
103 testConfig := getEnvironConfig(c, values)103 testConfig := getEnvironConfig(c, values)
104 c.Assert(testConfig.bootstrapHost(), gc.Equals, "hostname")104 c.Assert(testConfig.bootstrapHost(), gc.Equals, "hostname")
105 c.Assert(testConfig.bootstrapUser(), gc.Equals, "")105 c.Assert(testConfig.bootstrapUser(), gc.Equals, "")
@@ -111,7 +111,7 @@
111}111}
112112
113func (s *configSuite) TestStorageParams(c *gc.C) {113func (s *configSuite) TestStorageParams(c *gc.C) {
114 values := minimalConfigValues()114 values := MinimalConfigValues()
115 testConfig := getEnvironConfig(c, values)115 testConfig := getEnvironConfig(c, values)
116 c.Assert(testConfig.storageAddr(), gc.Equals, "hostname:8040")116 c.Assert(testConfig.storageAddr(), gc.Equals, "hostname:8040")
117 c.Assert(testConfig.storageListenAddr(), gc.Equals, ":8040")117 c.Assert(testConfig.storageListenAddr(), gc.Equals, ":8040")
118118
=== modified file 'provider/null/environ_test.go'
--- provider/null/environ_test.go 2014-01-08 05:49:24 +0000
+++ provider/null/environ_test.go 2014-01-29 10:09:08 +0000
@@ -29,15 +29,15 @@
29var _ = gc.Suite(&environSuite{})29var _ = gc.Suite(&environSuite{})
3030
31func (s *environSuite) SetUpTest(c *gc.C) {31func (s *environSuite) SetUpTest(c *gc.C) {
32 envConfig := getEnvironConfig(c, minimalConfigValues())32 envConfig := getEnvironConfig(c, MinimalConfigValues())
33 s.env = &nullEnviron{cfg: envConfig}33 s.env = &nullEnviron{cfg: envConfig}
34}34}
3535
36func (s *environSuite) TestSetConfig(c *gc.C) {36func (s *environSuite) TestSetConfig(c *gc.C) {
37 err := s.env.SetConfig(minimalConfig(c))37 err := s.env.SetConfig(MinimalConfig(c))
38 c.Assert(err, gc.IsNil)38 c.Assert(err, gc.IsNil)
3939
40 testConfig := minimalConfig(c)40 testConfig := MinimalConfig(c)
41 testConfig, err = testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})41 testConfig, err = testConfig.Apply(map[string]interface{}{"bootstrap-host": ""})
42 c.Assert(err, gc.IsNil)42 c.Assert(err, gc.IsNil)
43 err = s.env.SetConfig(testConfig)43 err = s.env.SetConfig(testConfig)
4444
=== added file 'provider/null/export_test.go'
--- provider/null/export_test.go 1970-01-01 00:00:00 +0000
+++ provider/null/export_test.go 2014-01-29 10:09:08 +0000
@@ -0,0 +1,8 @@
1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package null
5
6var (
7 ProviderInstance = nullProvider{}
8)
09
=== modified file 'provider/null/provider.go'
--- provider/null/provider.go 2013-10-15 05:11:29 +0000
+++ provider/null/provider.go 2014-01-29 10:09:08 +0000
@@ -22,7 +22,18 @@
22var errNoBootstrapHost = errors.New("bootstrap-host must be specified")22var errNoBootstrapHost = errors.New("bootstrap-host must be specified")
2323
24func (p nullProvider) Prepare(cfg *config.Config) (environs.Environ, error) {24func (p nullProvider) Prepare(cfg *config.Config) (environs.Environ, error) {
25 // TODO(rog) 2013-10-07 generate storage-auth-key if not set.25 if _, ok := cfg.UnknownAttrs()["storage-auth-key"].(string); !ok {
26 uuid, err := utils.NewUUID()
27 if err != nil {
28 return nil, err
29 }
30 cfg, err = cfg.Apply(map[string]interface{}{
31 "storage-auth-key": uuid.String(),
32 })
33 if err != nil {
34 return nil, err
35 }
36 }
26 return p.Open(cfg)37 return p.Open(cfg)
27}38}
2839
@@ -112,11 +123,7 @@
112 # bootstrap machine's Juju storage server will listen123 # bootstrap machine's Juju storage server will listen
113 # on. It defaults to ` + fmt.Sprint(defaultStoragePort) + `124 # on. It defaults to ` + fmt.Sprint(defaultStoragePort) + `
114 # storage-port: ` + fmt.Sprint(defaultStoragePort) + `125 # storage-port: ` + fmt.Sprint(defaultStoragePort) + `
115 126
116 # storage-auth-key holds the key used to authenticate
117 # to the storage servers. It will become unnecessary to
118 # give this option.
119 storage-auth-key: {{rand}}
120127
121`[1:]128`[1:]
122}129}
123130
=== added file 'provider/null/provider_test.go'
--- provider/null/provider_test.go 1970-01-01 00:00:00 +0000
+++ provider/null/provider_test.go 2014-01-29 10:09:08 +0000
@@ -0,0 +1,32 @@
1// Copyright 2014 Canonical Ltd.
2// Licensed under the AGPLv3, see LICENCE file for details.
3
4package null_test
5
6import (
7 gc "launchpad.net/gocheck"
8
9 "launchpad.net/juju-core/environs/config"
10 "launchpad.net/juju-core/provider/null"
11 jc "launchpad.net/juju-core/testing/checkers"
12 "launchpad.net/juju-core/testing/testbase"
13 "launchpad.net/juju-core/utils"
14)
15
16type providerSuite struct {
17 testbase.LoggingSuite
18}
19
20var _ = gc.Suite(&providerSuite{})
21
22func (s *providerSuite) TestPrepare(c *gc.C) {
23 minimal := null.MinimalConfigValues()
24 delete(minimal, "storage-auth-key")
25 testConfig, err := config.New(config.UseDefaults, minimal)
26 c.Assert(err, gc.IsNil)
27 env, err := null.ProviderInstance.Prepare(testConfig)
28 c.Assert(err, gc.IsNil)
29 cfg := env.Config()
30 key, _ := cfg.UnknownAttrs()["storage-auth-key"].(string)
31 c.Assert(key, jc.Satisfies, utils.IsValidUUIDString)
32}

Subscribers

People subscribed via source and target branches

to status/vote changes: