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
@@ -112,11 +123,7 @@
# bootstrap machine's Juju storage server will listen
# on. It defaults to ` + fmt.Sprint(defaultStoragePort) + `
# storage-port: ` + fmt.Sprint(defaultStoragePort) + `
-
- # storage-auth-key holds the key used to authenticate
- # to the storage servers. It will become unnecessary to
- # give this option.
- storage-auth-key: {{rand}}
+
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): machine_ test.go null/config_ test.go null/environ_ test.go null/export_ test.go null/provider. go null/provider_ test.go
A [revision details]
M cmd/jujud/
M provider/
M provider/
A provider/
M provider/
A provider/
Index: [revision details] 20140129060438- 5kse5gkrbnxkwu2 7
=== 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-
+New revision: <email address hidden>
Index: cmd/jujud/ machine_ test.go machine_ test.go' machine_ test.go 2014-01-29 04:59:18 +0000 machine_ test.go 2014-01-29 10:08:01 +0000
=== modified file 'cmd/jujud/
--- cmd/jujud/
+++ cmd/jujud/
@@ -31,8 +31,8 @@
charmtesting "launchpad. net/juju- core/state/ apiserver/ charmrevisionup dater/testing" net/juju- core/state/ testing" net/juju- core/state/ watcher" net/juju- core/testing" net/juju- core/testing" net/juju- core/testing" net/juju- core/testing/ checkers" net/juju- core/testing/ testbase" net/juju- core/tools"
statetesting "launchpad.
"launchpad.
+ "launchpad.
coretesting "launchpad.
- "launchpad.
jc "launchpad.
"launchpad.
"launchpad.
Index: provider/ null/config_ test.go null/config_ test.go' null/config_ test.go 2013-12-23 06:06:40 +0000 null/config_ test.go 2014-01-29 10:08:01 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -21,7 +21,7 @@
var _ = gc.Suite( &configSuite{ })
-func minimalConfigVa lues() map[string] interface{ } { lues() map[string] interface{ } { interface{ }{
+func MinimalConfigVa
return map[string]
"name": "test",
"type": provider.Null,
@@ -34,8 +34,8 @@
}
}
-func minimalConfig(c *gc.C) *config.Config { lues() lues() New(config. UseDefaults, minimal)
- minimal := minimalConfigVa
+func MinimalConfig(c *gc.C) *config.Config {
+ minimal := MinimalConfigVa
testConfig, err := config.
c.Assert(err, gc.IsNil)
return testConfig
@@ -50,7 +50,7 @@
}
func (s *configSuite) TestValidateCon fig(c *gc.C) { Apply(map[ string] interface{ }{"bootstrap- host": ""}) }.Validate( testConfig, nil) }.Validate( testConfig, nil)
- testConfig := minimalConfig(c)
+ testConfig := MinimalConfig(c)
testConfig, err :=
testConfig.
c.Assert(err, gc.IsNil)
_, err = nullProvider{
@@ -61,7 +61,7 @@
_, err = nullProvider{
c.Assert(err, gc.ErrorMatches, "storage-auth-key: expected string, got
nothing")
- testConfig = minimalConfig(c) }.Validate( testConfig, nil)
+ testConfig = MinimalConfig(c)
valid, err := nullProvider{
c.Assert(err, gc.IsNil)
@@ -73,7 +73,7 @@
}
func (s *configSuite) TestConfigMutab ility(c *gc.C) { }.Validate( testConfig, nil) trs() listen- ip": "10.0.0.123", Apply(map[ string] interface{ }{k: v}) }.Validate( testConfig, oldConfig)
- testConfig := minimalConfig(c)
+ testConfig := MinimalConfig(c)
valid, err := nullProvider{
c.Assert(err, gc.IsNil)
unknownAttrs := valid.UnknownAt
@@ -88,7 +88,7 @@
"storage-
"storage-port": int64(1234),
} {
- testConfig = minimalConfig(c)
+ testConfig = MinimalConfig(c)
testConfig, err = testConfig.
c.Assert(err, gc.IsNil)
_, err := nullProvider{
@@ -99,7 +99,7 @@
}
func (s *configSuite) TestBootstrapHo stUser( c *gc.C) { lues() lues() testConfig. bootstrapHost( ), gc.Equals, "hostname") testConfig. bootstrapUser( ), gc.Equals, "")
- values := minimalConfigVa
+ values := MinimalConfigVa
testConfig := getEnvironConfig(c, values)
c.Assert(
c.Assert(
@@ -111,7 +111,7 @@
}
func (s *configSuite) TestStorageParams(c *gc.C) { lues() lues() testConfig. storageAddr( ), gc.Equals, "hostname:8040") testConfig. storageListenAd dr(), gc.Equals, ":8040")
- values := minimalConfigVa
+ values := MinimalConfigVa
testConfig := getEnvironConfig(c, values)
c.Assert(
c.Assert(
Index: provider/ null/environ_ test.go null/environ_ test.go' null/environ_ test.go 2014-01-08 05:49:24 +0000 null/environ_ test.go 2014-01-29 10:08:01 +0000 &environSuite{ })
=== modified file 'provider/
--- provider/
+++ provider/
@@ -29,15 +29,15 @@
var _ = gc.Suite(
func (s *environSuite) SetUpTest(c *gc.C) { lues()) lues())
- envConfig := getEnvironConfig(c, minimalConfigVa
+ envConfig := getEnvironConfig(c, MinimalConfigVa
s.env = &nullEnviron{cfg: envConfig}
}
func (s *environSuite) TestSetConfig(c *gc.C) { (minimalConfig( c)) (MinimalConfig( c))
- err := s.env.SetConfig
+ err := s.env.SetConfig
c.Assert(err, gc.IsNil)
- testConfig := minimalConfig(c) Apply(map[ string] interface{ }{"bootstrap- host": ""}) (testConfig)
+ testConfig := MinimalConfig(c)
testConfig, err =
testConfig.
c.Assert(err, gc.IsNil)
err = s.env.SetConfig
Index: provider/ null/export_ test.go null/export_ test.go' null/export_ test.go 1970-01-01 00:00:00 +0000 null/export_ test.go 2014-01-29 10:08:01 +0000
=== added file 'provider/
--- provider/
+++ provider/
@@ -0,0 +1,8 @@
+// Copyright 2014 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package null
+
+var (
+ ProviderInstance = nullProvider{}
+)
Index: provider/ null/provider. go null/provider. go' null/provider. go 2013-10-15 05:11:29 +0000 null/provider. go 2014-01-29 10:08:01 +0000 New("bootstrap- host must be specified")
=== modified file 'provider/
--- provider/
+++ provider/
@@ -22,7 +22,18 @@
var errNoBootstrapHost = errors.
func (p nullProvider) Prepare(cfg *config.Config) (environs.Environ, s()["storage- auth-key" ].(string) ; !ok { map[string] interface{ }{
error) {
- // TODO(rog) 2013-10-07 generate storage-auth-key if not set.
+ if _, ok := cfg.UnknownAttr
+ uuid, err := utils.NewUUID()
+ if err != nil {
+ return nil, err
+ }
+ cfg, err = cfg.Apply(
+ "storage-auth-key": uuid.String(),
+ })
+ if err != nil {
+ return nil, err
+ }
+ }
return p.Open(cfg)
}
@@ -112,11 +123,7 @@ defaultStorageP ort) + ` defaultStorageP ort) + `
# bootstrap machine's Juju storage server will listen
# on. It defaults to ` + fmt.Sprint(
# storage-port: ` + fmt.Sprint(
-
- # storage-auth-key holds the key used to authenticate
- # to the storage servers. It will become unnecessary to
- # give this option.
- storage-auth-key: {{rand}}
+
`[1:]
}
Index: provider/ null/provider_ test.go null/provider_ test.go' null/provider_ test.go 1970-01-01 00:00:00 +0000 null/provider_ test.go 2014-01-29 10:08:01 +0000 net/gocheck" net/juju- core/environs/ config" net/juju- core/provider/ null" net/juju- core/testing/ checkers" net/juju- core/testing/ testbase" net/juju- core/utils" LoggingSuite &providerSuite{ }) figValues( ) New(config. UseDefaults, minimal) stance. Prepare( testConfig) s()["storage- auth-key" ].(string) IDString)
=== added file 'provider/
--- provider/
+++ provider/
@@ -0,0 +1,32 @@
+// Copyright 2014 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package null_test
+
+import (
+ gc "launchpad.
+
+ "launchpad.
+ "launchpad.
+ jc "launchpad.
+ "launchpad.
+ "launchpad.
+)
+
+type providerSuite struct {
+ testbase.
+}
+
+var _ = gc.Suite(
+
+func (s *providerSuite) TestPrepare(c *gc.C) {
+ minimal := null.MinimalCon
+ delete(minimal, "storage-auth-key")
+ testConfig, err := config.
+ c.Assert(err, gc.IsNil)
+ env, err := null.ProviderIn
+ c.Assert(err, gc.IsNil)
+ cfg := env.Config()
+ key, _ := cfg.UnknownAttr
+ c.Assert(key, jc.Satisfies, utils.IsValidUU
+}