@@ -29,12 +29,14 @@ const mountpoint = "/mnt/image"
2929var (
3030 project = flag .String ("project" , "" , "GCE project whose resources will be used for creating the image" )
3131 zone = flag .String ("zone" , "us-central1-a" , "GCE zone used for creating relevant resources" )
32+ arch = flag .String ("arch" , "x86_64" , "architecture of GCE image. Supports either x86_64 or arm64" )
3233 source_image_project = flag .String ("source-image-project" , "" , "Source image GCP project" )
3334 source_image = flag .String ("source-image" , "" , "Source image name" )
3435 image_name = flag .String ("image-name" , "" , "output GCE image name" )
3536)
3637
3738type createImageOpts struct {
39+ Arch gce.Arch
3840 SourceImageProject string
3941 SourceImage string
4042 ImageName string
@@ -85,7 +87,7 @@ func createImageMain(project, zone string, opts createImageOpts) error {
8587 }
8688 log .Printf ("disk created: %q" , attachedDiskName )
8789 log .Println ("creating instance..." )
88- ins , err := h .CreateInstance (insName , gce . ArchX86 )
90+ ins , err := h .CreateInstance (insName , opts . Arch )
8991 if err != nil {
9092 return fmt .Errorf ("failed to create instance: %w" , err )
9193 }
@@ -151,6 +153,9 @@ func main() {
151153 if * zone == "" {
152154 log .Fatal ("usage: `-zone` must not be empty" )
153155 }
156+ if * arch == "" {
157+ log .Fatal ("usage: `-arch` must not be empty" )
158+ }
154159 if * source_image_project == "" {
155160 log .Fatal ("usage: `-source-image-project` must not be empty" )
156161 }
@@ -160,8 +165,13 @@ func main() {
160165 if * image_name == "" {
161166 log .Fatal ("usage: `-image-name` must not be empty" )
162167 }
168+ architecture , err := gce .ParseArch (* arch )
169+ if err != nil {
170+ log .Fatal (err )
171+ }
163172
164173 opts := createImageOpts {
174+ Arch : architecture ,
165175 SourceImageProject : * source_image_project ,
166176 SourceImage : * source_image ,
167177 ImageName : * image_name ,
0 commit comments