~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to environs/tools/storage.go

  • Committer: Tarmac
  • Author(s): Tim Penhey
  • Date: 2013-07-17 01:59:54 UTC
  • mfrom: (1263.6.13 find-jujud)
  • Revision ID: tarmac-20130717015954-vbfukru18ysccfxq
[r=thumper] Use pre-built jujud if found.

Instead of rebuilding jujud everytime we want to upload some tools, try to
find jujud next to the juju being executed.

https://codereview.appspot.com/11326043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
        "fmt"
9
9
        "io"
10
10
        "io/ioutil"
11
 
        "launchpad.net/juju-core/log"
 
11
        "os"
 
12
        "strings"
 
13
 
12
14
        "launchpad.net/juju-core/state"
13
15
        "launchpad.net/juju-core/version"
14
 
        "os"
15
 
        "strings"
16
16
)
17
17
 
18
18
var ErrNoTools = errors.New("no tools available")
46
46
// ReadList returns a List of the tools in store with the given major version.
47
47
// If store contains no such tools, it returns ErrNoMatches.
48
48
func ReadList(storage URLLister, majorVersion int) (List, error) {
49
 
        log.Debugf("environs/tools: reading v%d.* tools", majorVersion)
 
49
        logger.Debugf("reading v%d.* tools", majorVersion)
50
50
        names, err := storage.List(toolPrefix)
51
51
        if err != nil {
52
52
                return nil, err
66
66
                if t.Major != majorVersion {
67
67
                        continue
68
68
                }
69
 
                log.Debugf("environs/tools: found %s", vers)
 
69
                logger.Debugf("found %s", vers)
70
70
                if t.URL, err = storage.URL(name); err != nil {
71
71
                        return nil, err
72
72
                }
99
99
        // TODO(rog) find binaries from $PATH when not using a development
100
100
        // version of juju within a $GOPATH.
101
101
 
 
102
        logger.Debugf("Uploading tools for %v", fakeSeries)
102
103
        // We create the entire archive before asking the environment to
103
104
        // start uploading so that we can be sure we have archived
104
105
        // correctly.
117
118
                return nil, fmt.Errorf("cannot stat newly made tools archive: %v", err)
118
119
        }
119
120
        size := fileInfo.Size()
120
 
        log.Infof("environs/tools: built %v (%dkB)", toolsVersion, (size+512)/1024)
 
121
        logger.Infof("built %v (%dkB)", toolsVersion, (size+512)/1024)
121
122
        putTools := func(vers version.Binary) (string, error) {
122
123
                if _, err := f.Seek(0, 0); err != nil {
123
124
                        return "", fmt.Errorf("cannot seek to start of tools archive: %v", err)
124
125
                }
125
126
                name := StorageName(vers)
126
 
                log.Infof("environs/tools: uploading %s", vers)
 
127
                logger.Infof("uploading %s", vers)
127
128
                if err := storage.Put(name, f, size); err != nil {
128
129
                        return "", err
129
130
                }