Index: environs/bootstrap/synctools.go |
=== modified file 'environs/bootstrap/synctools.go' |
--- environs/bootstrap/synctools.go 2014-03-19 02:55:15 +0000 |
+++ environs/bootstrap/synctools.go 2014-03-19 22:02:00 +0000 |
@@ -27,8 +27,10 @@ |
` |
// UploadTools uploads tools for the specified series and any other relevant series to |
-// the environment storage, after which it sets the agent-version. |
-func UploadTools(env environs.Environ, toolsArch *string, allowRelease bool, bootstrapSeries ...string) error { |
+// the environment storage, after which it sets the agent-version. If forceVersion is true, |
+// we allow uploading release tools versions and allow uploading even when the agent-version is |
+// already set in the environment. |
+func UploadTools(env environs.Environ, toolsArch *string, forceVersion bool, bootstrapSeries ...string) error { |
logger.Infof("checking that upload is possible") |
// Check the series are valid. |
for _, series := range bootstrapSeries { |
@@ -37,15 +39,15 @@ |
} |
} |
// See that we are allowed to upload the tools. |
- if err := validateUploadAllowed(env, toolsArch, allowRelease); err != nil { |
+ if err := validateUploadAllowed(env, toolsArch, forceVersion); err != nil { |
return err |
} |
cfg := env.Config() |
- forceVersion := uploadVersion(version.Current.Number, nil) |
+ explicitVersion := uploadVersion(version.Current.Number, nil) |
uploadSeries := SeriesToUpload(cfg, bootstrapSeries) |
logger.Infof("uploading tools for series %s", uploadSeries) |
- tools, err := sync.Upload(env.Storage(), &forceVersion, uploadSeries...) |
+ tools, err := sync.Upload(env.Storage(), &explicitVersion, uploadSeries...) |
if err != nil { |
return err |
} |
@@ -91,13 +93,14 @@ |
// validateUploadAllowed returns an error if an attempt to upload tools should |
// not be allowed. |
-func validateUploadAllowed(env environs.Environ, toolsArch *string, allowRelease bool) error { |
- // First, check that there isn't already an agent version specified, and that we |
- // are running a development version. |
- if _, hasAgentVersion := env.Config().AgentVersion(); hasAgentVersion || (!allowRelease && !version.Current.IsDev()) { |
- return fmt.Errorf(noToolsNoUploadMessage) |
+func validateUploadAllowed(env environs.Environ, toolsArch *string, forceVersion bool) error { |
+ if !forceVersion { |
+ // First, check that there isn't already an agent version specified, and that we |
+ // are running a development version. |
+ if _, hasAgentVersion := env.Config().AgentVersion(); hasAgentVersion || !version.Current.IsDev() { |
+ return fmt.Errorf(noToolsNoUploadMessage) |
+ } |
} |
- |
// Now check that the architecture for which we are setting up an |
// environment matches that from which we are bootstrapping. |
hostArch := arch.HostArch() |