Merge lp:~axwalk/juju-core/reinstate-cmd-juju-bootstrap-source 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: 2091
Proposed branch: lp:~axwalk/juju-core/reinstate-cmd-juju-bootstrap-source
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 77 lines (+41/-1)
2 files modified
cmd/juju/bootstrap.go (+7/-1)
cmd/juju/bootstrap_test.go (+34/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/reinstate-cmd-juju-bootstrap-source
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+196040@code.launchpad.net

Commit message

cmd/juju: reinstate --source for juju bootstrap

In r2069 I removed the --source option of juju bootstrap.
It has since come to light that this remains a desirable
option for MAAS users, and that we should go through a
two-step deprecation anyway.

I've reinstated the option, but changed the way it's
implemented: it now simply overrides the value of
environs/sync.DefaultToolsLocation.

https://codereview.appspot.com/29990044/

Description of the change

cmd/juju: reinstate --source for juju bootstrap

In r2069 I removed the --source option of juju bootstrap.
It has since come to light that this remains a desirable
option for MAAS users, and that we should go through a
two-step deprecation anyway.

I've reinstated the option, but changed the way it's
implemented: it now simply overrides the value of
environs/sync.DefaultToolsLocation.

https://codereview.appspot.com/29990044/

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

Reviewers: mp+196040_code.launchpad.net,

Message:
Please take a look.

Description:
cmd/juju: reinstate --source for juju bootstrap

In r2069 I removed the --source option of juju bootstrap.
It has since come to light that this remains a desirable
option for MAAS users, and that we should go through a
two-step deprecation anyway.

I've reinstated the option, but changed the way it's
implemented: it now simply overrides the value of
environs/sync.DefaultToolsLocation.

https://code.launchpad.net/~axwalk/juju-core/reinstate-cmd-juju-bootstrap-source/+merge/196040

(do not edit description out of merge proposal)

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

Affected files (+48, -1 lines):
   A [revision details]
   M cmd/juju/bootstrap.go
   M cmd/juju/bootstrap_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-20131120142833-kh97nkpng5qaps4o
+New revision: <email address hidden>

Index: cmd/juju/bootstrap.go
=== modified file 'cmd/juju/bootstrap.go'
--- cmd/juju/bootstrap.go 2013-11-18 05:41:36 +0000
+++ cmd/juju/bootstrap.go 2013-11-21 01:18:17 +0000
@@ -52,6 +52,7 @@
   Constraints constraints.Value
   UploadTools bool
   Series []string
+ Source string
  }

  func (c *BootstrapCommand) Info() *cmd.Info {
@@ -67,6 +68,7 @@
   f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set
environment constraints")
   f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of
tools before bootstrapping")
   f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied
comma-separated series list")
+ f.StringVar(&c.Source, "source", "", "local path to use as tools source")
  }

  func (c *BootstrapCommand) Init(args []string) error {
@@ -98,7 +100,11 @@
   if err := bootstrap.EnsureNotBootstrapped(environ); err != nil {
    return err
   }
-
+ // If --source is specified, override the default tools source.
+ if c.Source != "" {
+ logger.Infof("Setting default tools source: %s", c.Source)
+ sync.DefaultToolsLocation = c.Source
+ }
   // TODO (wallyworld): 2013-09-20 bug 1227931
   // We can set a custom tools data source instead of doing an
   // unecessary upload.

Index: cmd/juju/bootstrap_test.go
=== modified file 'cmd/juju/bootstrap_test.go'
--- cmd/juju/bootstrap_test.go 2013-11-18 06:27:04 +0000
+++ cmd/juju/bootstrap_test.go 2013-11-21 01:18:17 +0000
@@ -313,6 +313,45 @@
   c.Check(coretesting.Stdout(ctx2), gc.Equals, "")
  }

+func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
+ // Prepare a tools directory for testing and store the
+ // dummy tools in there.
+ sourceDir := createToolsSource(c, vAll)
+
+ // Change the version and ensure its later restoring.
+ origVersion := version.Current
+ version.Current.Number = version.MustParse("1.2.0")
+ defer func() {
+ version.Current = origVersion
+ }()
+
+ // Create home with dummy provider and remove all
+ // of its envtools.
+ env, fake := makeEmptyFakeHome(c)
+ defer fake.Restore()
+
+ // Bootstrap the environment with an i...

Read more...

Revision history for this message
Ian Booth (wallyworld) wrote :

LGTM with the test split up

https://codereview.appspot.com/29990044/diff/1/cmd/juju/bootstrap_test.go
File cmd/juju/bootstrap_test.go (right):

https://codereview.appspot.com/29990044/diff/1/cmd/juju/bootstrap_test.go#newcode316
cmd/juju/bootstrap_test.go:316: func (s *BootstrapSuite)
TestAutoSyncLocalSource(c *gc.C) {
I'd really like this split into 2 tests, one with invalid source, one
with valid source.

https://codereview.appspot.com/29990044/

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

Please take a look.

https://codereview.appspot.com/29990044/diff/1/cmd/juju/bootstrap_test.go
File cmd/juju/bootstrap_test.go (right):

https://codereview.appspot.com/29990044/diff/1/cmd/juju/bootstrap_test.go#newcode316
cmd/juju/bootstrap_test.go:316: func (s *BootstrapSuite)
TestAutoSyncLocalSource(c *gc.C) {
On 2013/11/22 00:02:02, wallyworld wrote:
> I'd really like this split into 2 tests, one with invalid source, one
with valid
> source.

Done.

https://codereview.appspot.com/29990044/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/bootstrap.go'
2--- cmd/juju/bootstrap.go 2013-11-18 05:41:36 +0000
3+++ cmd/juju/bootstrap.go 2013-11-22 01:59:00 +0000
4@@ -52,6 +52,7 @@
5 Constraints constraints.Value
6 UploadTools bool
7 Series []string
8+ Source string
9 }
10
11 func (c *BootstrapCommand) Info() *cmd.Info {
12@@ -67,6 +68,7 @@
13 f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set environment constraints")
14 f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping")
15 f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied comma-separated series list")
16+ f.StringVar(&c.Source, "source", "", "local path to use as tools source")
17 }
18
19 func (c *BootstrapCommand) Init(args []string) error {
20@@ -98,7 +100,11 @@
21 if err := bootstrap.EnsureNotBootstrapped(environ); err != nil {
22 return err
23 }
24-
25+ // If --source is specified, override the default tools source.
26+ if c.Source != "" {
27+ logger.Infof("Setting default tools source: %s", c.Source)
28+ sync.DefaultToolsLocation = c.Source
29+ }
30 // TODO (wallyworld): 2013-09-20 bug 1227931
31 // We can set a custom tools data source instead of doing an
32 // unecessary upload.
33
34=== modified file 'cmd/juju/bootstrap_test.go'
35--- cmd/juju/bootstrap_test.go 2013-11-18 06:27:04 +0000
36+++ cmd/juju/bootstrap_test.go 2013-11-22 01:59:00 +0000
37@@ -313,6 +313,40 @@
38 c.Check(coretesting.Stdout(ctx2), gc.Equals, "")
39 }
40
41+func (s *BootstrapSuite) TestInvalidLocalSource(c *gc.C) {
42+ s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
43+ env, fake := makeEmptyFakeHome(c)
44+ defer fake.Restore()
45+
46+ // Bootstrap the environment with an invalid source.
47+ // The command returns with an error.
48+ ctx := coretesting.Context(c)
49+ code := cmd.Main(&BootstrapCommand{}, ctx, []string{"--source", c.MkDir()})
50+ c.Check(code, gc.Equals, 1)
51+
52+ // Now check that there are no tools available.
53+ _, err := envtools.FindTools(
54+ env, version.Current.Major, version.Current.Minor, coretools.Filter{}, envtools.DoNotAllowRetry)
55+ c.Assert(err, gc.FitsTypeOf, errors.NotFoundf(""))
56+}
57+
58+func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
59+ sourceDir := createToolsSource(c, vAll)
60+ s.PatchValue(&version.Current.Number, version.MustParse("1.2.0"))
61+ env, fake := makeEmptyFakeHome(c)
62+ defer fake.Restore()
63+
64+ // Bootstrap the environment with the valid source.
65+ // The bootstrapping has to show no error, because the tools
66+ // are automatically synchronized.
67+ ctx := coretesting.Context(c)
68+ code := cmd.Main(&BootstrapCommand{}, ctx, []string{"--source", sourceDir})
69+ c.Check(code, gc.Equals, 0)
70+
71+ // Now check the available tools which are the 1.2.0 envtools.
72+ checkTools(c, env, v120All)
73+}
74+
75 func (s *BootstrapSuite) setupAutoUploadTest(c *gc.C, vers, series string) environs.Environ {
76 s.PatchValue(&sync.Upload, mockUploadTools)
77 sourceDir := createToolsSource(c, vAll)

Subscribers

People subscribed via source and target branches

to status/vote changes: