Esempio n. 1
0
func (s *storageSuite) TestHTTPStorage(c *C) {
	sr := ec2.NewHTTPStorageReader(s.storage.Location())
	list, err := sr.List("tools/juju-")
	c.Assert(err, IsNil)
	c.Assert(len(list), Equals, 6)

	url, err := sr.URL(list[0])
	c.Assert(err, IsNil)
	c.Assert(url, Matches, "http://127.0.0.1:.*/tools/juju-1.0.0-precise-amd64.tgz")

	rc, err := sr.Get(list[0])
	c.Assert(err, IsNil)
	defer rc.Close()

	buf := &bytes.Buffer{}
	_, err = io.Copy(buf, rc)
	c.Assert(err, IsNil)
	c.Assert(buf.String(), Equals, "1.0.0-precise-amd64")
}
Esempio n. 2
0
// selectSourceStorage returns a storage reader based on the passed source flag.
func selectSourceStorage(sourceFlagValue string) (environs.StorageReader, error) {
	if sourceFlagValue == "" {
		return ec2.NewHTTPStorageReader(defaultToolsLocation), nil
	}
	return newFileStorageReader(sourceFlagValue)
}
Esempio n. 3
0
// selectSourceStorage returns a storage reader based on the source setting.
func selectSourceStorage(ctx *SyncContext) (environs.StorageReader, error) {
	if ctx.Source == "" {
		return ec2.NewHTTPStorageReader(DefaultToolsLocation), nil
	}
	return newFileStorageReader(ctx.Source)
}