Skip to content

Commit 98ddf55

Browse files
authored
Merge pull request juju#5780 from axw/separate-bootstrap-config
bootstrap: separate bootstrap config Extract bootstrap-specific config into its own config struct, in the environs/bootstrap package. Things that can only be defined or generated at bootstrap time belong here. We now generate the admin-secret, ca-cert and ca-private-key in bootstrap config. Bootstrap timeouts are also now specified here, and will no longer show up in the output of get-model-config. environs/config has been simplified as a result of this change: there is no longer a need to read files in that code. This makes the code easier to reason about - there is no longer any chance that instantating an environs/config.Config will read files server-side. The controller config schema has been dropped, and the new controller.NewConfig function is made responsible for creating a complete controller config from user-specified attributes, setting defaults as necessary. environs/config no longer refers to controller config, except to validate that no schema field reuse controller config field names. Even this can probably be dropped in time, as users become accustomed to the new world order. (Review request: http://reviews.vapour.ws/r/5224/)
2 parents b6d9fbd + d40b8a7 commit 98ddf55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1042
-1484
lines changed

api/testing/macaroonsuite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *MacaroonSuite) SetUpTest(c *gc.C) {
5252
}
5353
return []checkers.Caveat{checkers.DeclaredCaveat("username", username)}, nil
5454
})
55-
s.JujuConnSuite.ConfigAttrs = map[string]interface{}{
55+
s.JujuConnSuite.ControllerConfigAttrs = map[string]interface{}{
5656
controller.IdentityURL: s.discharger.Location(),
5757
}
5858
s.JujuConnSuite.SetUpTest(c)

apiserver/common/controllerconfig_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func (f *fakeControllerAccessor) ControllerConfig() (controller.Config, error) {
3535
return map[string]interface{}{
3636
controller.ControllerUUIDKey: testing.ModelTag.Id(),
3737
controller.CACertKey: testing.CACert,
38-
controller.CAPrivateKey: testing.CAKey,
3938
controller.ApiPort: 4321,
4039
controller.StatePort: 1234,
4140
}, nil
@@ -54,7 +53,6 @@ func (*controllerConfigSuite) TestControllerConfigSuccess(c *gc.C) {
5453
c.Assert(err, jc.ErrorIsNil)
5554
c.Assert(map[string]interface{}(result.Config), jc.DeepEquals, map[string]interface{}{
5655
"ca-cert": testing.CACert,
57-
"ca-private-key": testing.CAKey,
5856
"controller-uuid": "deadbeef-0bad-400d-8000-4b1d0d06f00d",
5957
"state-port": 1234,
6058
"api-port": 4321,

apiserver/common/modelwatcher_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ func testingEnvConfig(c *gc.C) *config.Config {
124124
modelcmd.BootstrapContext(testing.Context(c)),
125125
jujuclienttesting.NewMemStore(),
126126
bootstrap.PrepareParams{
127-
ControllerConfig: testing.FakeControllerBootstrapConfig(),
127+
ControllerConfig: testing.FakeControllerConfig(),
128128
ControllerName: "dummycontroller",
129129
BaseConfig: dummy.SampleConfig(),
130130
CloudName: "dummy",
131+
AdminSecret: "admin-secret",
131132
},
132133
)
133134
c.Assert(err, jc.ErrorIsNil)

apiserver/imagemetadata/functions_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ func (s *funcSuite) SetUpTest(c *gc.C) {
3737
envtesting.BootstrapContext(c),
3838
jujuclienttesting.NewMemStore(),
3939
bootstrap.PrepareParams{
40-
ControllerConfig: testing.FakeControllerBootstrapConfig(),
40+
ControllerConfig: testing.FakeControllerConfig(),
4141
ControllerName: "dummycontroller",
4242
BaseConfig: mockConfig(),
4343
CloudName: "dummy",
44+
AdminSecret: "admin-secret",
4445
},
4546
)
4647
c.Assert(err, jc.ErrorIsNil)

apiserver/imagemetadata/package_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ func testConfig(c *gc.C) *config.Config {
127127
envtesting.BootstrapContext(c),
128128
jujuclienttesting.NewMemStore(),
129129
bootstrap.PrepareParams{
130-
ControllerConfig: coretesting.FakeControllerBootstrapConfig(),
130+
ControllerConfig: coretesting.FakeControllerConfig(),
131131
ControllerName: "dummycontroller",
132132
BaseConfig: attrs,
133133
CloudName: "dummy",
134+
AdminSecret: "admin-secret",
134135
},
135136
)
136137
c.Assert(err, jc.ErrorIsNil)

apiserver/imagemetadata/updatefrompublished_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ func (s *imageMetadataUpdateSuite) TestUpdateFromPublishedImagesForProviderWithN
169169
modelcmd.BootstrapContext(testing.Context(c)),
170170
jujuclienttesting.NewMemStore(),
171171
bootstrap.PrepareParams{
172-
ControllerConfig: testing.FakeControllerBootstrapConfig(),
172+
ControllerConfig: testing.FakeControllerConfig(),
173173
ControllerName: "dummycontroller",
174174
BaseConfig: dummy.SampleConfig(),
175175
CloudName: "dummy",
176+
AdminSecret: "admin-secret",
176177
},
177178
)
178179
c.Assert(err, jc.ErrorIsNil)

apiserver/migrationtarget/migrationtarget_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ func (s *Suite) SetUpTest(c *gc.C) {
3939
modelcmd.BootstrapContext(testing.Context(c)),
4040
jujuclienttesting.NewMemStore(),
4141
bootstrap.PrepareParams{
42-
ControllerConfig: testing.FakeControllerBootstrapConfig(),
42+
ControllerConfig: testing.FakeControllerConfig(),
4343
ControllerName: "dummycontroller",
4444
BaseConfig: dummy.SampleConfig(),
4545
CloudName: "dummy",
46+
AdminSecret: "admin-secret",
4647
},
4748
)
4849
c.Assert(err, jc.ErrorIsNil)

apiserver/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ var _ = gc.Suite(&macaroonServerSuite{})
331331

332332
func (s *macaroonServerSuite) SetUpTest(c *gc.C) {
333333
s.discharger = bakerytest.NewDischarger(nil, noCheck)
334-
s.ConfigAttrs = map[string]interface{}{
334+
s.ControllerConfigAttrs = map[string]interface{}{
335335
controller.IdentityURL: s.discharger.Location(),
336336
}
337337
s.JujuConnSuite.SetUpTest(c)
@@ -381,7 +381,7 @@ func (s *macaroonServerWrongPublicKeySuite) SetUpTest(c *gc.C) {
381381
s.discharger = bakerytest.NewDischarger(nil, noCheck)
382382
wrongKey, err := bakery.GenerateKey()
383383
c.Assert(err, gc.IsNil)
384-
s.ConfigAttrs = map[string]interface{}{
384+
s.ControllerConfigAttrs = map[string]interface{}{
385385
controller.IdentityURL: s.discharger.Location(),
386386
controller.IdentityPublicKey: wrongKey.Public.String(),
387387
}

cloudconfig/cloudinit/renderscript_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *configureSuite) getCloudConfig(c *gc.C, controller bool, vers version.B
6262
modelConfig := testConfig(c, controller, vers)
6363
if controller {
6464
icfg, err = instancecfg.NewBootstrapInstanceConfig(
65-
coretesting.FakeControllerBootstrapConfig(),
65+
coretesting.FakeControllerConfig(),
6666
constraints.Value{}, constraints.Value{},
6767
vers.Series, "",
6868
)
@@ -80,6 +80,13 @@ func (s *configureSuite) getCloudConfig(c *gc.C, controller bool, vers version.B
8080
icfg.Bootstrap.HostedModelConfig = map[string]interface{}{
8181
"name": "hosted-model",
8282
}
83+
icfg.Bootstrap.StateServingInfo = params.StateServingInfo{
84+
Cert: coretesting.ServerCert,
85+
PrivateKey: coretesting.ServerKey,
86+
CAPrivateKey: coretesting.CAKey,
87+
StatePort: 123,
88+
APIPort: 456,
89+
}
8390
icfg.Jobs = []multiwatcher.MachineJob{multiwatcher.JobManageModel, multiwatcher.JobHostUnits}
8491
icfg.Bootstrap.StateServingInfo = params.StateServingInfo{
8592
Cert: coretesting.ServerCert,

cloudconfig/providerinit/providerinit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (*CloudInitSuite) testUserData(c *gc.C, series string, bootstrap bool) {
183183
err = cfg.SetTools(toolsList)
184184
c.Assert(err, jc.ErrorIsNil)
185185
if bootstrap {
186-
controllerCfg := testing.FakeControllerBootstrapConfig()
186+
controllerCfg := testing.FakeControllerConfig()
187187
cfg.Bootstrap = &instancecfg.BootstrapConfig{
188188
StateInitializationParams: instancecfg.StateInitializationParams{
189189
ControllerConfig: controllerCfg,

0 commit comments

Comments
 (0)