@@ -18,6 +18,7 @@ package azure
18
18
import (
19
19
"context"
20
20
"fmt"
21
+ "runtime"
21
22
"time"
22
23
23
24
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
@@ -26,7 +27,7 @@ import (
26
27
"github.com/coreos/coreos-assembler/mantle/util"
27
28
)
28
29
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 ) {
30
31
ctx := context .Background ()
31
32
32
33
// Ensure the Azure Shared Image Gallery exists. BeginCreateOrUpdate will create the gallery
@@ -54,6 +55,19 @@ func (a *API) CreateGalleryImage(name, galleryName, resourceGroup, sourceImageID
54
55
},
55
56
}
56
57
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
+
57
71
// Create a Gallery Image Definition with the specified Hyper-V generation (V1 or V2).
58
72
galleryImagePoller , err := a .galImgClient .BeginCreateOrUpdate (ctx , resourceGroup , galleryName , name , armcompute.GalleryImage {
59
73
Location : & a .opts .Location ,
@@ -66,7 +80,8 @@ func (a *API) CreateGalleryImage(name, galleryName, resourceGroup, sourceImageID
66
80
Offer : to .Ptr (name ),
67
81
SKU : to .Ptr (util .RandomName ("sku" )),
68
82
},
69
- Features : galleryImageFeatures ,
83
+ Features : galleryImageFeatures ,
84
+ Architecture : & azureArch ,
70
85
},
71
86
}, nil )
72
87
if err != nil {
0 commit comments