github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/provider/common/supportedarchitectures.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package common 5 6 import ( 7 "github.com/juju/utils/set" 8 9 "github.com/juju/juju/environs" 10 "github.com/juju/juju/environs/imagemetadata" 11 ) 12 13 // SupportedArchitectures returns all the image architectures for env matching the constraints. 14 func SupportedArchitectures(env environs.Environ, imageConstraint *imagemetadata.ImageConstraint) ([]string, error) { 15 sources, err := environs.ImageMetadataSources(env) 16 if err != nil { 17 return nil, err 18 } 19 matchingImages, _, err := imagemetadata.Fetch(sources, imageConstraint) 20 if err != nil { 21 return nil, err 22 } 23 var arches = set.NewStrings() 24 for _, im := range matchingImages { 25 arches.Add(im.Arch) 26 } 27 return arches.Values(), nil 28 }