Skip to content

Commit

Permalink
r/windows_virtual_machine: fixing the test when generating a vm
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Aug 9, 2023
1 parent cd170bf commit a5c73e6
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ func (WindowsVirtualMachineResource) generalizeVirtualMachine(ctx context.Contex
return err
}

if _, ok := ctx.Deadline(); !ok {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, 15*time.Minute)
defer cancel()
}

command := []string{
"$cmd = \"$Env:SystemRoot\\system32\\sysprep\\sysprep.exe\"",
"$args = \"/generalize /oobe /mode:vm /quit\"",
Expand Down Expand Up @@ -504,8 +510,11 @@ func (r WindowsVirtualMachineResource) cancelExistingAgreement(publisher string,
return func(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error {
client := clients.Compute.MarketplaceAgreementsClient
subscriptionId := clients.Account.SubscriptionId
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(15*time.Minute))
defer cancel()
if _, ok := ctx.Deadline(); !ok {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, 15*time.Minute)
defer cancel()
}

idGet := agreements.NewOfferPlanID(subscriptionId, publisher, offer, sku)
idCancel := agreements.NewPlanID(subscriptionId, publisher, offer, sku)
Expand Down

0 comments on commit a5c73e6

Please sign in to comment.