Skip to content

Commit

Permalink
Merge pull request #8077 from hmlanigan/bug1721604
Browse files Browse the repository at this point in the history
fix bug 1721604

## Description of change

Juju bootstrap cli results should be the same as running bootstrap interactive.  If bootstrap, cli only, doesn't specify a region, but finds one to use, use it for config too.

## QA steps

One:
1. set region config for an openstack cloud, suggest network since you can't bootstrap without it most of the time.
2. juju bootstrap <openstack-cloud>

Two:
bootstrap a cloud without regions, such as localhost

## Documentation changes

n/a

## Bug reference

https://bugs.launchpad.net/juju/+bug/1721604
  • Loading branch information
jujubot committed Nov 15, 2017
2 parents 14b3ca6 + 0dac3cf commit 469e113
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
4 changes: 4 additions & 0 deletions cmd/juju/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ func (c *bootstrapCommand) Run(ctx *cmd.Context) (resultErr error) {
if c.controllerName == "" {
c.controllerName = defaultControllerName(cloud.Name, region.Name)
}
// set a Region so it's config can be found below.
if c.Region == "" {
c.Region = region.Name
}

config, err := c.bootstrapConfigs(ctx, cloud, provider)
if err != nil {
Expand Down
68 changes: 40 additions & 28 deletions cmd/juju/commands/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,19 @@ func (s *BootstrapSuite) TestBootstrapAttributesInheritedOverDefaults(c *gc.C) {
})
}

func (s *BootstrapSuite) TestBootstrapRegionConfigNoRegionSpecified(c *gc.C) {
resetJujuXDGDataHome(c)

var bootstrap fakeBootstrapFuncs
s.PatchValue(&getBootstrapFuncs, func() BootstrapInterface {
return &bootstrap
})

_, err := cmdtesting.RunCommand(c, s.newBootstrapCommand(), "dummy-cloud-dummy-region-config")
c.Assert(err, gc.Equals, cmd.ErrSilent)
c.Assert(bootstrap.args.ControllerInheritedConfig["secret"], gc.Equals, "region-test")
}

func (s *BootstrapSuite) TestBootstrapRegionConfigAttributesOverCloudConfig(c *gc.C) {
/* Test that cloud config attributes are overwritten by region config
attributes by setting both to something different in the config setup.
Expand Down Expand Up @@ -1692,24 +1705,25 @@ func (s *BootstrapSuite) TestBootstrapPrintClouds(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(cmdtesting.Stdout(ctx), jc.DeepEquals, `
You can bootstrap on these clouds. See ‘--regions <cloud>’ for all regions.
Cloud Credentials Default Region
aws fred us-west-1
mary
aws-china
aws-gov
azure
azure-china
cloudsigma
google
joyent
oracle
rackspace
localhost
dummy-cloud joe home
dummy-cloud-with-config
dummy-cloud-with-region-config
dummy-cloud-without-regions
many-credentials-no-auth-types
Cloud Credentials Default Region
aws fred us-west-1
mary
aws-china
aws-gov
azure
azure-china
cloudsigma
google
joyent
oracle
rackspace
localhost
dummy-cloud joe home
dummy-cloud-dummy-region-config
dummy-cloud-with-config
dummy-cloud-with-region-config
dummy-cloud-without-regions
many-credentials-no-auth-types
You will need to have a credential if you want to bootstrap on a cloud, see
‘juju autoload-credentials’ and ‘juju add-credential’. The first credential
Expand Down Expand Up @@ -1856,22 +1870,14 @@ clouds:
region-2:
dummy-cloud-without-regions:
type: dummy
dummy-cloud-with-region-config:
dummy-cloud-dummy-region-config:
type: dummy
regions:
region-1:
region-2:
config:
network: cloud-network
region-config:
region-1:
network: region-network
dummy-cloud-with-config:
type: dummy
config:
broken: Bootstrap
controller: not-a-bool
use-floating-ip: true
secret: region-test
dummy-cloud-with-region-config:
type: dummy
regions:
Expand All @@ -1882,6 +1888,12 @@ clouds:
region-config:
region-1:
network: region-network
dummy-cloud-with-config:
type: dummy
config:
broken: Bootstrap
controller: not-a-bool
use-floating-ip: true
many-credentials-no-auth-types:
type: many-credentials
`[1:]), 0644)
Expand Down

0 comments on commit 469e113

Please sign in to comment.