7
// MongoURL figures out from where to retrieve a copy of MongoDB compatible with
8
// the given version from the given environment. The search locations are (in order):
9
// - the environment specific storage
10
// - the public storage
11
// - a "well known" EC2 bucket
12
func MongoURL(env Environ, series, architecture string) string {
13
path := MongoStoragePath(series, architecture)
14
url, err := findMongo(env.Storage(), path)
18
url, err = findMongo(env.PublicStorage(), path)
22
// TODO(thumper): this should at least check that the fallback option
23
// exists before returning it. lp:1164220
24
return fmt.Sprintf("http://juju-dist.s3.amazonaws.com/%s", path)
27
// Return the URL of a compatible MongoDB (if it exists) from the storage,
28
// for the given series and architecture (in vers).
29
func findMongo(store StorageReader, path string) (string, error) {
30
names, err := store.List(path)
35
return "", &NotFoundError{fmt.Errorf("%s not found", path)}
37
url, err := store.URL(names[0])
44
7
// MongoStoragePath returns the path that is used to
45
8
// retrieve the given version of mongodb in a Storage.
46
9
func MongoStoragePath(series, architecture string) string {