@@ -55,6 +55,7 @@ func (v *DebSrcsFlag) Set(s string) error {
5555var (
5656 project = flag .String ("project" , "" , "GCP project whose resources will be used for creating the amended image" )
5757 zone = flag .String ("zone" , "us-central1-a" , "GCP zone used for creating relevant resources" )
58+ arch = flag .String ("arch" , "x86_64" , "architecture of GCE image. Supports either x86_64 or arm64" )
5859 source_image_project = flag .String ("source-image-project" , "" , "Source image GCP project" )
5960 source_image = flag .String ("source-image" , "" , "Source image name" )
6061 image_name = flag .String ("image-name" , "" , "output GCE image name" )
@@ -68,6 +69,7 @@ func init() {
6869}
6970
7071type amendImageOpts struct {
72+ Arch gce.Arch
7173 SourceImageProject string
7274 SourceImage string
7375 ImageName string
@@ -184,7 +186,7 @@ func amendImageMain(project, zone string, opts amendImageOpts) error {
184186 defer cleanupDeleteDisk (h , attachedDiskName )
185187
186188 log .Println ("creating instance..." )
187- _ , err = h .CreateInstance (insName , gce . ArchX86 )
189+ _ , err = h .CreateInstance (insName , opts . Arch )
188190 if err != nil {
189191 return fmt .Errorf ("failed to create instance: %w" , err )
190192 }
@@ -258,6 +260,9 @@ func main() {
258260 if * zone == "" {
259261 log .Fatal ("usage: `-zone` must not be empty" )
260262 }
263+ if * arch == "" {
264+ log .Fatal ("usage: `-arch` must not be empty" )
265+ }
261266 if * source_image_project == "" {
262267 log .Fatal ("usage: `-source-image-project` must not be empty" )
263268 }
@@ -273,8 +278,13 @@ func main() {
273278 if * container_image_src == "" {
274279 log .Fatal ("usage: `-container-image-src` must not be empty" )
275280 }
281+ architecture , err := gce .ParseArch (* arch )
282+ if err != nil {
283+ log .Fatal (err )
284+ }
276285
277286 opts := amendImageOpts {
287+ Arch : architecture ,
278288 SourceImageProject : * source_image_project ,
279289 SourceImage : * source_image ,
280290 ImageName : * image_name ,
0 commit comments