Skip to content

Commit 8331f09

Browse files
committed
Find pre-built tool automatically
1 parent 911de19 commit 8331f09

Some content is hidden

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

54 files changed

+559
-702
lines changed

agent/tools/toolsdir.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ func UnpackTools(dataDir string, tools *coretools.Tools, r io.Reader) (err error
7373
return err
7474
}
7575
defer os.Remove(f.Name())
76-
// TODO(wallyworld) - 2013-09-24 bug=1229512
77-
// When we can ensure all tools records have valid checksums recorded,
78-
// we can remove this test short circuit.
7976
gzipSHA256 := fmt.Sprintf("%x", sha256hash.Sum(nil))
80-
if tools.SHA256 != "" && tools.SHA256 != gzipSHA256 {
77+
if tools.SHA256 != gzipSHA256 {
8178
return fmt.Errorf("tarball sha256 mismatch, expected %s, got %s", tools.SHA256, gzipSHA256)
8279
}
8380

cloud/clouds_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import (
1111
gc "gopkg.in/check.v1"
1212

1313
"github.com/juju/juju/cloud"
14-
"github.com/juju/juju/juju/osenv"
1514
"github.com/juju/juju/testing"
1615
)
1716

1817
type cloudSuite struct {
19-
testing.BaseSuite
18+
testing.FakeJujuXDGDataHomeSuite
2019
}
2120

2221
var _ = gc.Suite(&cloudSuite{})
@@ -168,9 +167,6 @@ func (s *cloudSuite) TestGeneratedPublicCloudInfo(c *gc.C) {
168167
}
169168

170169
func (s *cloudSuite) TestWritePublicCloudsMetadata(c *gc.C) {
171-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
172-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
173-
174170
clouds := map[string]cloud.Cloud{
175171
"aws-me": cloud.Cloud{
176172
Type: "aws",

cloudconfig/providerinit/providerinit_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/juju/juju/cloudconfig/instancecfg"
2525
"github.com/juju/juju/cloudconfig/providerinit"
2626
"github.com/juju/juju/environs/config"
27-
"github.com/juju/juju/juju/osenv"
2827
"github.com/juju/juju/juju/paths"
2928
"github.com/juju/juju/mongo"
3029
"github.com/juju/juju/provider/dummy"
@@ -45,7 +44,7 @@ func dummySampleConfig() testing.Attrs {
4544
}
4645

4746
type CloudInitSuite struct {
48-
testing.BaseSuite
47+
testing.FakeJujuXDGDataHomeSuite
4948
}
5049

5150
var _ = gc.Suite(&CloudInitSuite{})
@@ -140,8 +139,6 @@ func (s *CloudInitSuite) TestControllerUserDataPrecise(c *gc.C) {
140139
}
141140

142141
func (*CloudInitSuite) testUserData(c *gc.C, series string, bootstrap bool) {
143-
testJujuXDGDataHome := c.MkDir()
144-
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(testJujuXDGDataHome))
145142
// Use actual series paths instead of local defaults
146143
logDir := must(paths.LogDir(series))
147144
metricsSpoolDir := must(paths.MetricsSpoolDir(series))

cmd/juju/backups/restore.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ func NewRestoreCommand() cmd.Command {
4848
// it is invoked with "juju restore-backup".
4949
type restoreCommand struct {
5050
CommandBase
51-
constraints constraints.Value
52-
filename string
53-
backupId string
54-
bootstrap bool
55-
uploadTools bool
51+
constraints constraints.Value
52+
filename string
53+
backupId string
54+
bootstrap bool
55+
buildAgent bool
56+
uploadToolsDeprecated bool
5657

5758
newAPIClientFunc func() (RestoreAPI, error)
5859
newEnvironFunc func(environs.OpenParams) (environs.Environ, error)
@@ -111,7 +112,8 @@ func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) {
111112
f.BoolVar(&c.bootstrap, "b", false, "Bootstrap a new state machine")
112113
f.StringVar(&c.filename, "file", "", "Provide a file to be used as the backup.")
113114
f.StringVar(&c.backupId, "id", "", "Provide the name of the backup to be restored")
114-
f.BoolVar(&c.uploadTools, "upload-tools", false, "Upload tools if bootstraping a new machine")
115+
f.BoolVar(&c.buildAgent, "build-agent", false, "Build binary agent if bootstraping a new machine")
116+
f.BoolVar(&c.uploadToolsDeprecated, "upload-tools", false, "DEPRECATED: see build-agent")
115117
}
116118

117119
// Init is where the preconditions for this commands can be checked.
@@ -125,6 +127,12 @@ func (c *restoreCommand) Init(args []string) error {
125127
if c.backupId != "" && c.bootstrap {
126128
return errors.Errorf("it is not possible to rebootstrap and restore from an id.")
127129
}
130+
131+
// TODO(wallyworld) - remove me when CI scripts updated
132+
if c.uploadToolsDeprecated {
133+
c.buildAgent = c.uploadToolsDeprecated
134+
}
135+
128136
var err error
129137
if c.filename != "" {
130138
c.filename, err = filepath.Abs(c.filename)
@@ -316,8 +324,8 @@ func (c *restoreCommand) rebootstrap(ctx *cmd.Context, meta *params.BackupsMetad
316324
CloudCredentialName: params.CredentialName,
317325
CloudCredential: params.Cloud.Credential,
318326
ModelConstraints: c.constraints,
319-
UploadTools: c.uploadTools,
320-
BuildToolsTarball: sync.BuildToolsTarball,
327+
BuildAgent: c.buildAgent,
328+
BuildAgentTarball: sync.BuildAgentTarball,
321329
ControllerConfig: params.ControllerConfig,
322330
HostedModelConfig: hostedModelConfig,
323331
BootstrapSeries: meta.Series,

cmd/juju/cloud/add_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ import (
1616
)
1717

1818
type addSuite struct {
19-
testing.BaseSuite
19+
testing.FakeJujuXDGDataHomeSuite
2020
}
2121

2222
var _ = gc.Suite(&addSuite{})
2323

24-
func (s *addSuite) SetUpTest(c *gc.C) {
25-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
26-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
27-
}
28-
2924
func (s *addSuite) TestAddBadArgs(c *gc.C) {
3025
addCmd := cloud.NewAddCloudCommand()
3126
_, err := testing.RunCommand(c, addCmd)

cmd/juju/cloud/defaultcredential_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,16 @@ import (
1212

1313
jujucloud "github.com/juju/juju/cloud"
1414
"github.com/juju/juju/cmd/juju/cloud"
15-
"github.com/juju/juju/juju/osenv"
1615
"github.com/juju/juju/jujuclient/jujuclienttesting"
1716
"github.com/juju/juju/testing"
1817
)
1918

2019
type defaultCredentialSuite struct {
21-
testing.BaseSuite
20+
testing.FakeJujuXDGDataHomeSuite
2221
}
2322

2423
var _ = gc.Suite(&defaultCredentialSuite{})
2524

26-
func (s *defaultCredentialSuite) SetUpTest(c *gc.C) {
27-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
28-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
29-
}
30-
3125
func (s *defaultCredentialSuite) TestBadArgs(c *gc.C) {
3226
cmd := cloud.NewSetDefaultCredentialCommand()
3327
_, err := testing.RunCommand(c, cmd)

cmd/juju/cloud/defaultregion_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,16 @@ import (
1313
"github.com/juju/cmd"
1414
jujucloud "github.com/juju/juju/cloud"
1515
"github.com/juju/juju/cmd/juju/cloud"
16-
"github.com/juju/juju/juju/osenv"
1716
"github.com/juju/juju/jujuclient/jujuclienttesting"
1817
"github.com/juju/juju/testing"
1918
)
2019

2120
type defaultRegionSuite struct {
22-
testing.BaseSuite
21+
testing.FakeJujuXDGDataHomeSuite
2322
}
2423

2524
var _ = gc.Suite(&defaultRegionSuite{})
2625

27-
func (s *defaultRegionSuite) SetUpTest(c *gc.C) {
28-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
29-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
30-
}
31-
3226
func (s *defaultRegionSuite) TestBadArgs(c *gc.C) {
3327
cmd := cloud.NewSetDefaultRegionCommand()
3428
_, err := testing.RunCommand(c, cmd)

cmd/juju/cloud/remove_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ import (
1616
)
1717

1818
type removeSuite struct {
19-
testing.BaseSuite
19+
testing.FakeJujuXDGDataHomeSuite
2020
}
2121

2222
var _ = gc.Suite(&removeSuite{})
2323

24-
func (s *removeSuite) SetUpTest(c *gc.C) {
25-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
26-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
27-
}
28-
2924
func (s *removeSuite) TestRemoveBadArgs(c *gc.C) {
3025
cmd := cloud.NewRemoveCloudCommand()
3126
_, err := testing.RunCommand(c, cmd)

cmd/juju/cloud/updateclouds.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ See also: clouds
4343
`
4444

4545
// NewUpdateCloudsCommand returns a command to update cloud information.
46-
func NewUpdateCloudsCommand() cmd.Command {
46+
var NewUpdateCloudsCommand = func() cmd.Command {
47+
return newUpdateCloudsCommand()
48+
}
49+
50+
func newUpdateCloudsCommand() cmd.Command {
4751
return &updateCloudsCommand{
4852
publicSigningKey: keys.JujuPublicKey,
4953
publicCloudURL: "https://streams.canonical.com/juju/public-clouds.syaml",
@@ -59,7 +63,7 @@ func (c *updateCloudsCommand) Info() *cmd.Info {
5963
}
6064

6165
func (c *updateCloudsCommand) Run(ctxt *cmd.Context) error {
62-
fmt.Fprint(ctxt.Stdout, "Fetching latest public cloud list...\n")
66+
fmt.Fprint(ctxt.Stderr, "Fetching latest public cloud list...\n")
6367
client := utils.GetHTTPClient(utils.VerifySSLHostnames)
6468
resp, err := client.Get(c.publicCloudURL)
6569
if err != nil {
@@ -70,7 +74,7 @@ func (c *updateCloudsCommand) Run(ctxt *cmd.Context) error {
7074
if resp.StatusCode != http.StatusOK {
7175
switch resp.StatusCode {
7276
case http.StatusNotFound:
73-
fmt.Fprintln(ctxt.Stdout, "Public cloud list is unavailable right now.")
77+
fmt.Fprintln(ctxt.Stderr, "Public cloud list is unavailable right now.")
7478
return nil
7579
case http.StatusUnauthorized:
7680
return errors.Unauthorizedf("unauthorised access to URL %q", c.publicCloudURL)
@@ -96,14 +100,14 @@ func (c *updateCloudsCommand) Run(ctxt *cmd.Context) error {
96100
return err
97101
}
98102
if sameCloudInfo {
99-
fmt.Fprintln(ctxt.Stdout, "Your list of public clouds is up to date, see `juju clouds`.")
103+
fmt.Fprintln(ctxt.Stderr, "Your list of public clouds is up to date, see `juju clouds`.")
100104
return nil
101105
}
102106
if err := jujucloud.WritePublicCloudMetadata(newPublicClouds); err != nil {
103107
return errors.Annotate(err, "error writing new local public cloud data")
104108
}
105109
updateDetails := diffClouds(newPublicClouds, currentPublicClouds)
106-
fmt.Fprintln(ctxt.Stdout, fmt.Sprintf("Updated your list of public clouds with %s", updateDetails))
110+
fmt.Fprintln(ctxt.Stderr, fmt.Sprintf("Updated your list of public clouds with %s", updateDetails))
107111
return nil
108112
}
109113

cmd/juju/cloud/updateclouds_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@ import (
1818
jujucloud "github.com/juju/juju/cloud"
1919
"github.com/juju/juju/cmd/juju/cloud"
2020
sstesting "github.com/juju/juju/environs/simplestreams/testing"
21-
"github.com/juju/juju/juju/osenv"
2221
"github.com/juju/juju/testing"
2322
)
2423

2524
type updateCloudsSuite struct {
26-
testing.BaseSuite
25+
testing.FakeJujuXDGDataHomeSuite
2726
}
2827

2928
var _ = gc.Suite(&updateCloudsSuite{})
3029

31-
func (s *updateCloudsSuite) SetUpTest(c *gc.C) {
32-
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
33-
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
34-
}
35-
3630
func encodeCloudYAML(c *gc.C, yaml string) string {
3731
// TODO(wallyworld) - move test signing key elsewhere
3832
keyring, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(sstesting.SignedMetadataPrivateKey))
@@ -83,7 +77,7 @@ func (s *updateCloudsSuite) run(c *gc.C, url, errMsg string) string {
8377
errString := strings.Replace(err.Error(), "\n", "", -1)
8478
c.Assert(errString, gc.Matches, errMsg)
8579
}
86-
return testing.Stdout(out)
80+
return testing.Stderr(out)
8781
}
8882

8983
func (s *updateCloudsSuite) Test404(c *gc.C) {

0 commit comments

Comments
 (0)