Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(174)

Unified Diff: environs/tools.go

Issue 6408049: environs: turn environment configuration into a concrete type
Patch Set: environs: turn environment configuration into a concrete type Created 12 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « environs/open_test.go ('k') | environs/tools_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: environs/tools.go
=== modified file 'environs/tools.go'
--- environs/tools.go 2012-06-21 20:40:39 +0000
+++ environs/tools.go 2012-07-17 01:34:28 +0000
@@ -6,40 +6,16 @@
"fmt"
"io"
"io/ioutil"
+ "launchpad.net/juju-core/environs/config"
"launchpad.net/juju-core/log"
"launchpad.net/juju-core/version"
"os"
"os/exec"
"path/filepath"
"regexp"
- "runtime"
"strings"
)
-var CurrentSeries = readSeries("/etc/lsb-release") // current Ubuntu release name.
-var CurrentArch = ubuntuArch(runtime.GOARCH)
-
-func readSeries(releaseFile string) string {
- data, err := ioutil.ReadFile(releaseFile)
- if err != nil {
- return "unknown"
- }
- for _, line := range strings.Split(string(data), "\n") {
- const p = "DISTRIB_CODENAME="
- if strings.HasPrefix(line, p) {
- return strings.Trim(line[len(p):], "\t '\"")
- }
- }
- return "unknown"
-}
-
-func ubuntuArch(arch string) string {
- if arch == "386" {
- arch = "i386"
- }
- return arch
-}
-
var toolPrefix = "tools/juju-"
var toolFilePat = regexp.MustCompile(`^` + toolPrefix + `(\d+\.\d+\.\d+)-([^-]+)-([^-]+)\.tgz$`)
@@ -76,7 +52,7 @@
if err != nil {
return err
}
- p := ToolsPath(version.Current, CurrentSeries, CurrentArch)
+ p := ToolsPath(version.Current, config.CurrentSeries, config.CurrentArch)
log.Printf("environs: putting tools %v", p)
return storage.Put(p, f, fi.Size())
}
@@ -177,7 +153,7 @@
// GetTools finds the latest compatible version of the juju tools
// and downloads them into the given directory.
func GetTools(env Environ, dir string) error {
- storage, path, err := findTools(env, toolsSpec{version.Current, CurrentSeries, CurrentArch})
+ storage, path, err := findTools(env, toolsSpec{version.Current, config.CurrentSeries, config.CurrentArch})
if err != nil {
return err
}
« no previous file with comments | « environs/open_test.go ('k') | environs/tools_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b