@@ -18,6 +18,7 @@ package azure
1818import (
1919 "context"
2020 "fmt"
21+ "runtime"
2122 "time"
2223
2324 "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
@@ -26,7 +27,7 @@ import (
2627 "github.com/coreos/coreos-assembler/mantle/util"
2728)
2829
29- func (a * API ) CreateGalleryImage (name , galleryName , resourceGroup , sourceImageID string ) (armcompute.GalleryImageVersion , error ) {
30+ func (a * API ) CreateGalleryImage (name , galleryName , resourceGroup , sourceImageID , architecture string ) (armcompute.GalleryImageVersion , error ) {
3031 ctx := context .Background ()
3132
3233 // Ensure the Azure Shared Image Gallery exists. BeginCreateOrUpdate will create the gallery
@@ -54,6 +55,19 @@ func (a *API) CreateGalleryImage(name, galleryName, resourceGroup, sourceImageID
5455 },
5556 }
5657
58+ var azureArch armcompute.Architecture
59+ if architecture == "" {
60+ architecture = runtime .GOARCH
61+ }
62+ switch architecture {
63+ case "amd64" , "x86_64" :
64+ azureArch = armcompute .ArchitectureX64
65+ case "arm64" , "aarch64" :
66+ azureArch = armcompute .ArchitectureArm64
67+ default :
68+ return armcompute.GalleryImageVersion {}, fmt .Errorf ("unsupported azure architecture %q" , architecture )
69+ }
70+
5771 // Create a Gallery Image Definition with the specified Hyper-V generation (V1 or V2).
5872 galleryImagePoller , err := a .galImgClient .BeginCreateOrUpdate (ctx , resourceGroup , galleryName , name , armcompute.GalleryImage {
5973 Location : & a .opts .Location ,
@@ -66,7 +80,8 @@ func (a *API) CreateGalleryImage(name, galleryName, resourceGroup, sourceImageID
6680 Offer : to .Ptr (name ),
6781 SKU : to .Ptr (util .RandomName ("sku" )),
6882 },
69- Features : galleryImageFeatures ,
83+ Features : galleryImageFeatures ,
84+ Architecture : & azureArch ,
7085 },
7186 }, nil )
7287 if err != nil {
0 commit comments