@@ -233,6 +233,14 @@ type ScalewayImage struct {
233233 // FIXME: extra_volumes
234234}
235235
236+ // ScalewayImageIdentifier represents a Scaleway Image Identifier
237+ type ScalewayImageIdentifier struct {
238+ Identifier string
239+ Arch string
240+ Region string
241+ Owner string
242+ }
243+
236244// ScalewayOneImage represents the response of a GET /images/UUID API call
237245type ScalewayOneImage struct {
238246 Image ScalewayImage `json:"image,omitempty"`
@@ -1810,24 +1818,30 @@ func (s *ScalewayAPI) GetSnapshotID(needle string) (string, error) {
18101818}
18111819
18121820// GetImageID returns exactly one image matching or dies
1813- func (s * ScalewayAPI ) GetImageID (needle string , exitIfMissing bool ) (string , string , error ) {
1821+ func (s * ScalewayAPI ) GetImageID (needle string , exitIfMissing bool ) (* ScalewayImageIdentifier , error ) {
18141822 // Parses optional type prefix, i.e: "image:name" -> "name"
18151823 _ , needle = parseNeedle (needle )
18161824
18171825 images , err := s .ResolveImage (needle )
18181826 if err != nil {
1819- return "" , "" , fmt .Errorf ("Unable to resolve image %s: %s" , needle , err )
1827+ return nil , fmt .Errorf ("Unable to resolve image %s: %s" , needle , err )
18201828 }
18211829 if len (images ) == 1 {
1822- return images [0 ].Identifier , images [0 ].Arch , nil
1830+ return & ScalewayImageIdentifier {
1831+ Identifier : images [0 ].Identifier ,
1832+ Arch : images [0 ].Arch ,
1833+ // FIXME region, owner hardcoded
1834+ Region : "fr-1" ,
1835+ Owner : "" ,
1836+ }, nil
18231837 }
18241838 if len (images ) == 0 {
18251839 if exitIfMissing {
1826- return "" , "" , fmt .Errorf ("No such image: %s" , needle )
1840+ return nil , fmt .Errorf ("No such image: %s" , needle )
18271841 }
1828- return "" , "" , nil
1842+ return nil , nil
18291843 }
1830- return "" , "" , showResolverResults (needle , images )
1844+ return nil , showResolverResults (needle , images )
18311845}
18321846
18331847// GetSecurityGroups returns a ScalewaySecurityGroups
0 commit comments