Skip to content

Commit

Permalink
internal/v1: support Azure's HyperV generation
Browse files Browse the repository at this point in the history
  • Loading branch information
croissanne committed Nov 26, 2024
1 parent 02aa450 commit 41ef88a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
14 changes: 14 additions & 0 deletions internal/v1/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions internal/v1/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,15 @@ components:
Name of the created image.
Must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens.
The total length is limited to 60 characters.
hyper_v_generation:
type: string
enum:
- V1
- V2
default: V1
description: |
Choose the VM Image HyperV generation, different features on Azure are available
depending on the HyperV generation.
OCIUploadRequestOptions:
type: object
OSTree:
Expand Down
14 changes: 10 additions & 4 deletions internal/v1/handler_compose_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,17 @@ func (h *Handlers) buildUploadOptions(ctx echo.Context, ur UploadRequest, it Ima
subscriptionId = *uploadInfo.Azure.SubscriptionId
}

var hyperVGen *composer.AzureUploadOptionsHyperVGeneration
if uo.HyperVGeneration != nil {
hyperVGen = common.ToPtr(composer.AzureUploadOptionsHyperVGeneration(*uo.HyperVGeneration))
}

err = uploadOptions.FromAzureUploadOptions(composer.AzureUploadOptions{
TenantId: tenantId,
SubscriptionId: subscriptionId,
ResourceGroup: uo.ResourceGroup,
ImageName: uo.ImageName,
TenantId: tenantId,
SubscriptionId: subscriptionId,
ResourceGroup: uo.ResourceGroup,
ImageName: uo.ImageName,
HyperVGeneration: hyperVGen,
})
if err != nil {
return uploadOptions, "", err
Expand Down
18 changes: 10 additions & 8 deletions internal/v1/handler_post_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,10 +1465,11 @@ func TestComposeCustomizations(t *testing.T) {
}))
var auo UploadRequest_Options
require.NoError(t, auo.FromAzureUploadRequestOptions(AzureUploadRequestOptions{
ResourceGroup: "group",
SubscriptionId: common.ToPtr("id"),
TenantId: common.ToPtr("tenant"),
ImageName: common.ToPtr("azure-image"),
ResourceGroup: "group",
SubscriptionId: common.ToPtr("id"),
TenantId: common.ToPtr("tenant"),
ImageName: common.ToPtr("azure-image"),
HyperVGeneration: common.ToPtr(V2),
}))
var auo2 UploadRequest_Options
require.NoError(t, auo2.FromAzureUploadRequestOptions(AzureUploadRequestOptions{
Expand Down Expand Up @@ -1957,10 +1958,11 @@ func TestComposeCustomizations(t *testing.T) {
},
},
UploadOptions: makeUploadOptions(t, composer.AzureUploadOptions{
ImageName: common.ToPtr("azure-image"),
ResourceGroup: "group",
SubscriptionId: "id",
TenantId: "tenant",
ImageName: common.ToPtr("azure-image"),
ResourceGroup: "group",
SubscriptionId: "id",
TenantId: "tenant",
HyperVGeneration: common.ToPtr(composer.V2),
}),
},
},
Expand Down

0 comments on commit 41ef88a

Please sign in to comment.