From c1bdd30878fe340ddeec561e1774bccd930c6aff Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Tue, 14 Nov 2023 07:53:24 -0700 Subject: [PATCH] Update privateclusters e2e test for SDKv2 --- test/e2e/azure_privatecluster.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/e2e/azure_privatecluster.go b/test/e2e/azure_privatecluster.go index e761d408f30..9aa3316ea5e 100644 --- a/test/e2e/azure_privatecluster.go +++ b/test/e2e/azure_privatecluster.go @@ -26,6 +26,8 @@ import ( "path/filepath" "strings" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2021-11-01/compute" "github.com/Azure/azure-sdk-for-go/services/msi/mgmt/2018-11-30/msi" "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network" @@ -171,12 +173,11 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat // Check that azure bastion is provisioned successfully. { - By("verifying the Azure Bastion Host was create successfully") - settings, err := auth.GetSettingsFromEnvironment() - Expect(err).To(BeNil()) + By("verifying the Azure Bastion Host was created successfully") + cred, err := azidentity.NewDefaultAzureCredential(nil) + Expect(err).NotTo(HaveOccurred()) - azureBastionClient := network.NewBastionHostsClient(settings.GetSubscriptionID()) - azureBastionClient.Authorizer, err = azureutil.GetAuthorizer(settings) + azureBastionClient, err := armnetwork.NewBastionHostsClient(getSubscriptionID(Default), cred, nil) Expect(err).To(BeNil()) groupName := os.Getenv(AzureResourceGroup) @@ -189,19 +190,20 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat Steps: retryBackoffSteps, } retryFn := func() (bool, error) { - bastion, err := azureBastionClient.Get(ctx, groupName, azureBastionName) + resp, err := azureBastionClient.Get(ctx, groupName, azureBastionName, nil) if err != nil { return false, err } - switch bastion.ProvisioningState { - case network.ProvisioningStateSucceeded: + bastion := resp.BastionHost + switch ptr.Deref(bastion.Properties.ProvisioningState, "") { + case armnetwork.ProvisioningStateSucceeded: return true, nil - case network.ProvisioningStateUpdating: + case armnetwork.ProvisioningStateUpdating: // Wait for operation to complete. return false, nil default: - return false, errors.New(fmt.Sprintf("Azure Bastion provisioning failed with state: %q", bastion.ProvisioningState)) + return false, errors.New(fmt.Sprintf("Azure Bastion provisioning failed with state: %q", ptr.Deref(bastion.Properties.ProvisioningState, "(nil)"))) } } err = wait.ExponentialBackoff(backoff, retryFn)