@@ -51,15 +51,26 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
5151 errChan <- fmt .Errorf ("unable to parse creation date from the Scaleway API: %v" , err )
5252 return
5353 }
54- archs := []string {}
54+ archAvailable := make (map [string ]struct {})
55+ zoneAvailable := make (map [string ]struct {})
56+
5557 for _ , version := range val .Versions {
5658 if val .CurrentPublicVersion == version .ID {
5759 for _ , local := range version .LocalImages {
58- archs = append (archs , local .Arch )
60+ archAvailable [local .Arch ] = struct {}{}
61+ zoneAvailable [local .Zone ] = struct {}{}
5962 }
6063 break
6164 }
6265 }
66+ regions := []string {}
67+ for k := range zoneAvailable {
68+ regions = append (regions , k )
69+ }
70+ archs := []string {}
71+ for k := range archAvailable {
72+ archs = append (archs , k )
73+ }
6374 chEntries <- api.ScalewayImageInterface {
6475 Type : "image" ,
6576 CreationDate : creationDate ,
@@ -68,9 +79,8 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
6879 Tag : "latest" ,
6980 Organization : val .Organization .ID ,
7081 Public : val .Public ,
71- // FIXME the region should not be hardcoded
72- Region : "fr-1" ,
73- Archs : archs ,
82+ Region : regions ,
83+ Archs : archs ,
7484 }
7585 }
7686 }()
@@ -102,7 +112,7 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
102112 Public : false ,
103113 Organization : val .Organization ,
104114 // FIXME the region should not be hardcoded
105- Region : "fr-1" ,
115+ Region : [] string { "fr-1" } ,
106116 }
107117 }
108118 }()
@@ -125,7 +135,7 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
125135 Tag : "<bootscript>" ,
126136 Public : false ,
127137 // FIXME the region should not be hardcoded
128- Region : "fr-1" ,
138+ Region : [] string { "fr-1" } ,
129139 Archs : []string {val .Arch },
130140 }
131141 }
@@ -157,7 +167,7 @@ func RunImages(ctx CommandContext, args ImagesArgs) error {
157167 Public : false ,
158168 Organization : val .Organization ,
159169 // FIXME the region should not be hardcoded
160- Region : "fr-1" ,
170+ Region : [] string { "fr-1" } ,
161171 }
162172 }
163173 }()
0 commit comments