From e5e60ff31b0a84852161c2681edcd817404113fd Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Thu, 14 Sep 2023 12:29:13 -0600 Subject: [PATCH] Rename asyncpoller package to async --- azure/services/agentpools/agentpools.go | 6 +- azure/services/agentpools/agentpools_test.go | 24 ++++---- azure/services/agentpools/client.go | 6 +- .../asyncpoller.go => async/async.go} | 6 +- .../async_test.go} | 34 +++++------ .../{asyncpoller => async}/interfaces.go | 2 +- .../mock_async/async_mock.go} | 4 +- .../mock_async}/doc.go | 6 +- .../availabilitysets/availabilitysets.go | 8 +-- .../availabilitysets/availabilitysets_test.go | 36 +++++------ azure/services/bastionhosts/bastionhosts.go | 6 +- .../bastionhosts/bastionhosts_test.go | 22 +++---- azure/services/bastionhosts/client.go | 6 +- azure/services/disks/client.go | 4 +- azure/services/disks/disks.go | 6 +- azure/services/disks/disks_test.go | 14 ++--- azure/services/inboundnatrules/client.go | 6 +- .../inboundnatrules/inboundnatrules.go | 6 +- .../inboundnatrules/inboundnatrules_test.go | 28 ++++----- azure/services/loadbalancers/client.go | 6 +- azure/services/loadbalancers/loadbalancers.go | 6 +- .../loadbalancers/loadbalancers_test.go | 30 +++++----- azure/services/managedclusters/client.go | 6 +- .../managedclusters/managedclusters.go | 6 +- .../managedclusters/managedclusters_test.go | 24 ++++---- azure/services/natgateways/client.go | 6 +- azure/services/natgateways/natgateways.go | 6 +- .../services/natgateways/natgateways_test.go | 28 ++++----- azure/services/networkinterfaces/client.go | 6 +- .../networkinterfaces/networkinterfaces.go | 6 +- .../networkinterfaces_test.go | 28 ++++----- azure/services/privatedns/link_client.go | 6 +- azure/services/privatedns/privatedns.go | 16 ++--- azure/services/privatedns/privatedns_test.go | 60 +++++++++---------- azure/services/privatedns/zone_client.go | 6 +- azure/services/privateendpoints/client.go | 6 +- .../privateendpoints/privateendpoints.go | 6 +- .../privateendpoints/privateendpoints_test.go | 34 +++++------ azure/services/publicips/client.go | 6 +- azure/services/publicips/publicips.go | 10 ++-- azure/services/publicips/publicips_test.go | 28 ++++----- .../roleassignments/roleassignments.go | 10 ++-- .../roleassignments/roleassignments_test.go | 30 +++++----- azure/services/routetables/client.go | 6 +- azure/services/routetables/routetables.go | 6 +- .../services/routetables/routetables_test.go | 30 +++++----- azure/services/scalesets/client.go | 6 +- azure/services/scalesets/scalesets.go | 6 +- azure/services/scalesets/scalesets_test.go | 42 ++++++------- azure/services/scalesetvms/client.go | 6 +- azure/services/scalesetvms/scalesetvms.go | 10 ++-- .../services/scalesetvms/scalesetvms_test.go | 34 +++++------ azure/services/securitygroups/client.go | 6 +- .../services/securitygroups/securitygroups.go | 6 +- .../securitygroups/securitygroups_test.go | 34 +++++------ azure/services/subnets/client.go | 6 +- azure/services/subnets/subnets.go | 6 +- azure/services/subnets/subnets_test.go | 38 ++++++------ azure/services/virtualmachines/client.go | 6 +- .../virtualmachines/virtualmachines.go | 10 ++-- .../virtualmachines/virtualmachines_test.go | 34 +++++------ azure/services/virtualnetworks/client.go | 6 +- .../virtualnetworks/virtualnetworks.go | 10 ++-- .../virtualnetworks/virtualnetworks_test.go | 44 +++++++------- azure/services/vmextensions/client.go | 6 +- azure/services/vmextensions/vmextensions.go | 6 +- .../vmextensions/vmextensions_test.go | 16 ++--- azure/services/vnetpeerings/client.go | 6 +- azure/services/vnetpeerings/vnetpeerings.go | 6 +- .../vnetpeerings/vnetpeerings_test.go | 46 +++++++------- 70 files changed, 522 insertions(+), 522 deletions(-) rename azure/services/{asyncpoller/asyncpoller.go => async/async.go} (97%) rename azure/services/{asyncpoller/asyncpoller_test.go => async/async_test.go} (81%) rename azure/services/{asyncpoller => async}/interfaces.go (99%) rename azure/services/{asyncpoller/mock_asyncpoller/asyncpoller_mock.go => async/mock_async/async_mock.go} (99%) rename azure/services/{asyncpoller/mock_asyncpoller => async/mock_async}/doc.go (76%) diff --git a/azure/services/agentpools/agentpools.go b/azure/services/agentpools/agentpools.go index cc7d7c70474..3f0870847ad 100644 --- a/azure/services/agentpools/agentpools.go +++ b/azure/services/agentpools/agentpools.go @@ -24,7 +24,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) @@ -52,7 +52,7 @@ type AgentPoolScope interface { // Service provides operations on Azure resources. type Service struct { scope AgentPoolScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -63,7 +63,7 @@ func New(scope AgentPoolScope) (*Service, error) { } return &Service{ scope: scope, - Reconciler: asyncpoller.New[armcontainerservice.AgentPoolsClientCreateOrUpdateResponse, + Reconciler: async.New[armcontainerservice.AgentPoolsClientCreateOrUpdateResponse, armcontainerservice.AgentPoolsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/agentpools/agentpools_test.go b/azure/services/agentpools/agentpools_test.go index 95f76d364c8..60b37cdd1b1 100644 --- a/azure/services/agentpools/agentpools_test.go +++ b/azure/services/agentpools/agentpools_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) @@ -38,12 +38,12 @@ func TestReconcileAgentPools(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "agent pool successfully created with autoscaling enabled", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(sdkFakeAgentPool(sdkWithAutoscaling(true), sdkWithCount(1)), nil) @@ -55,7 +55,7 @@ func TestReconcileAgentPools(t *testing.T) { { name: "agent pool successfully created with autoscaling disabled", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(sdkFakeAgentPool(sdkWithAutoscaling(false), sdkWithCount(1)), nil) @@ -67,14 +67,14 @@ func TestReconcileAgentPools(t *testing.T) { { name: "no agent pool spec found", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AgentPoolSpec().Return(nil) }, }, { name: "fail to create a agent pool", expectedError: internalError.Error(), - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(nil, internalError) @@ -91,7 +91,7 @@ func TestReconcileAgentPools(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_agentpools.NewMockAgentPoolScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -115,12 +115,12 @@ func TestDeleteAgentPools(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "existing agent pool successfully deleted", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(nil) @@ -130,14 +130,14 @@ func TestDeleteAgentPools(t *testing.T) { { name: "no agent pool spec found", expectedError: "", - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AgentPoolSpec().Return(nil) }, }, { name: "fail to delete a agent pool", expectedError: internalError.Error(), - expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_agentpools.MockAgentPoolScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { fakeAgentPoolSpec := fakeAgentPool() s.AgentPoolSpec().Return(&fakeAgentPoolSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAgentPoolSpec, serviceName).Return(internalError) @@ -154,7 +154,7 @@ func TestDeleteAgentPools(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_agentpools.NewMockAgentPoolScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/agentpools/client.go b/azure/services/agentpools/client.go index 5494e0fe48f..65482617e9e 100644 --- a/azure/services/agentpools/client.go +++ b/azure/services/agentpools/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -89,7 +89,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. @@ -118,7 +118,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. diff --git a/azure/services/asyncpoller/asyncpoller.go b/azure/services/async/async.go similarity index 97% rename from azure/services/asyncpoller/asyncpoller.go rename to azure/services/async/async.go index b176ad1cc9d..ba3d6f4286a 100644 --- a/azure/services/asyncpoller/asyncpoller.go +++ b/azure/services/async/async.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package asyncpoller +package async import ( "context" @@ -54,7 +54,7 @@ func New[C, D any](scope FutureScope, createClient Creator[C], deleteClient Dele // CreateOrUpdateResource creates a new resource or updates an existing one asynchronously. func (s *Service[C, D]) CreateOrUpdateResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (result interface{}, err error) { - ctx, log, done := tele.StartSpanWithLogger(ctx, "asyncpoller.Service.CreateOrUpdateResource") + ctx, log, done := tele.StartSpanWithLogger(ctx, "async.Service.CreateOrUpdateResource") defer done() resourceName := spec.ResourceName() @@ -126,7 +126,7 @@ func (s *Service[C, D]) CreateOrUpdateResource(ctx context.Context, spec azure.R // DeleteResource deletes a resource asynchronously. func (s *Service[C, D]) DeleteResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (err error) { - ctx, log, done := tele.StartSpanWithLogger(ctx, "asyncpoller.Service.DeleteResource") + ctx, log, done := tele.StartSpanWithLogger(ctx, "async.Service.DeleteResource") defer done() resourceName := spec.ResourceName() diff --git a/azure/services/asyncpoller/asyncpoller_test.go b/azure/services/async/async_test.go similarity index 81% rename from azure/services/asyncpoller/asyncpoller_test.go rename to azure/services/async/async_test.go index eb430249918..cf49bb0f1e5 100644 --- a/azure/services/asyncpoller/asyncpoller_test.go +++ b/azure/services/async/async_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package asyncpoller +package async import ( "context" @@ -35,7 +35,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -45,13 +45,13 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { serviceName string expectedError string expectedResult interface{} - expect func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) + expect func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) }{ { name: "invalid future", serviceName: serviceName, expectedError: "could not decode future data, resetting long-running operation state", - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -65,7 +65,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { serviceName: serviceName, expectedError: "", expectedResult: fakeResource, - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -79,7 +79,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { name: "operation in progress", serviceName: serviceName, expectedError: "operation type PUT on Azure resource mock-resourcegroup/mock-resource is not done. Object will be requeued after 15s", - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -93,7 +93,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { name: "get returns resource not found error", serviceName: serviceName, expectedError: "operation type PUT on Azure resource mock-resourcegroup/mock-resource is not done. Object will be requeued after 15s", - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -109,7 +109,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { name: "get returns unexpected error", serviceName: serviceName, expectedError: "failed to get existing resource mock-resourcegroup/mock-resource (service: mock-service): foo. Object will be requeued after 15s", - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -123,7 +123,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { serviceName: serviceName, expectedError: "", expectedResult: fakeResource, - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -138,7 +138,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { serviceName: serviceName, expectedError: "failed to get desired parameters for resource mock-resourcegroup/mock-resource (service: mock-service): foo", expectedResult: nil, - expect: func(g *WithT, s *mock_asyncpoller.MockFutureScopeMockRecorder, c *mock_asyncpoller.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(g *WithT, s *mock_async.MockFutureScopeMockRecorder, c *mock_async.MockCreatorMockRecorder[MockCreator], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -158,8 +158,8 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { t.Parallel() mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() - scopeMock := mock_asyncpoller.NewMockFutureScope(mockCtrl) - creatorMock := mock_asyncpoller.NewMockCreator[MockCreator](mockCtrl) + scopeMock := mock_async.NewMockFutureScope(mockCtrl) + creatorMock := mock_async.NewMockCreator[MockCreator](mockCtrl) svc := New[MockCreator, MockDeleter](scopeMock, creatorMock, nil) specMock := mock_azure.NewMockResourceSpecGetter(mockCtrl) @@ -187,13 +187,13 @@ func TestServiceDeleteResource(t *testing.T) { serviceName string expectedError string expectedResult interface{} - expect func(s *mock_asyncpoller.MockFutureScopeMockRecorder, d *mock_asyncpoller.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) + expect func(s *mock_async.MockFutureScopeMockRecorder, d *mock_async.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) }{ { name: "invalid future", serviceName: serviceName, expectedError: "could not decode future data", - expect: func(s *mock_asyncpoller.MockFutureScopeMockRecorder, d *mock_asyncpoller.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(s *mock_async.MockFutureScopeMockRecorder, d *mock_async.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -206,7 +206,7 @@ func TestServiceDeleteResource(t *testing.T) { name: "valid future", serviceName: serviceName, expectedError: "", - expect: func(s *mock_asyncpoller.MockFutureScopeMockRecorder, d *mock_asyncpoller.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) { + expect: func(s *mock_async.MockFutureScopeMockRecorder, d *mock_async.MockDeleterMockRecorder[MockDeleter], r *mock_azure.MockResourceSpecGetterMockRecorder) { gomock.InOrder( r.ResourceName().Return(resourceName), r.ResourceGroupName().Return(resourceGroupName), @@ -226,8 +226,8 @@ func TestServiceDeleteResource(t *testing.T) { t.Parallel() mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() - scopeMock := mock_asyncpoller.NewMockFutureScope(mockCtrl) - deleterMock := mock_asyncpoller.NewMockDeleter[MockDeleter](mockCtrl) + scopeMock := mock_async.NewMockFutureScope(mockCtrl) + deleterMock := mock_async.NewMockDeleter[MockDeleter](mockCtrl) svc := New[MockCreator, MockDeleter](scopeMock, nil, deleterMock) specMock := mock_azure.NewMockResourceSpecGetter(mockCtrl) diff --git a/azure/services/asyncpoller/interfaces.go b/azure/services/async/interfaces.go similarity index 99% rename from azure/services/asyncpoller/interfaces.go rename to azure/services/async/interfaces.go index f6cf0f8e595..45f22e0bfd7 100644 --- a/azure/services/asyncpoller/interfaces.go +++ b/azure/services/async/interfaces.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package asyncpoller +package async import ( "context" diff --git a/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go b/azure/services/async/mock_async/async_mock.go similarity index 99% rename from azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go rename to azure/services/async/mock_async/async_mock.go index 0278822b882..cc50f8242e2 100644 --- a/azure/services/asyncpoller/mock_asyncpoller/asyncpoller_mock.go +++ b/azure/services/async/mock_async/async_mock.go @@ -17,8 +17,8 @@ limitations under the License. // Code generated by MockGen. DO NOT EDIT. // Source: ../interfaces.go -// Package mock_asyncpoller is a generated GoMock package. -package mock_asyncpoller +// Package mock_async is a generated GoMock package. +package mock_async import ( context "context" diff --git a/azure/services/asyncpoller/mock_asyncpoller/doc.go b/azure/services/async/mock_async/doc.go similarity index 76% rename from azure/services/asyncpoller/mock_asyncpoller/doc.go rename to azure/services/async/mock_async/doc.go index c6750cf8fb6..c5a15639d99 100644 --- a/azure/services/asyncpoller/mock_asyncpoller/doc.go +++ b/azure/services/async/mock_async/doc.go @@ -16,6 +16,6 @@ limitations under the License. // Run go generate to regenerate this mock. // -//go:generate ../../../../hack/tools/bin/mockgen -destination asyncpoller_mock.go -package mock_asyncpoller -source ../interfaces.go FutureHandler -//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt asyncpoller_mock.go > _asyncpoller_mock.go && mv _asyncpoller_mock.go asyncpoller_mock.go" -package mock_asyncpoller +//go:generate ../../../../hack/tools/bin/mockgen -destination async_mock.go -package mock_async -source ../interfaces.go FutureHandler +//go:generate /usr/bin/env bash -c "cat ../../../../hack/boilerplate/boilerplate.generatego.txt async_mock.go > _async_mock.go && mv _async_mock.go async_mock.go" +package mock_async diff --git a/azure/services/availabilitysets/availabilitysets.go b/azure/services/availabilitysets/availabilitysets.go index ee98eba1d72..6e3db673d51 100644 --- a/azure/services/availabilitysets/availabilitysets.go +++ b/azure/services/availabilitysets/availabilitysets.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -41,8 +41,8 @@ type AvailabilitySetScope interface { // Service provides operations on Azure resources. type Service struct { Scope AvailabilitySetScope - asyncpoller.Getter - asyncpoller.Reconciler + async.Getter + async.Reconciler resourceSKUCache *resourceskus.Cache } @@ -56,7 +56,7 @@ func New(scope AvailabilitySetScope, skuCache *resourceskus.Cache) (*Service, er Scope: scope, Getter: client, resourceSKUCache: skuCache, - Reconciler: asyncpoller.New[armcompute.AvailabilitySetsClientCreateOrUpdateResponse, + Reconciler: async.New[armcompute.AvailabilitySetsClientCreateOrUpdateResponse, armcompute.AvailabilitySetsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/availabilitysets/availabilitysets_test.go b/azure/services/availabilitysets/availabilitysets_test.go index db09622c8f5..39df89812f7 100644 --- a/azure/services/availabilitysets/availabilitysets_test.go +++ b/azure/services/availabilitysets/availabilitysets_test.go @@ -29,7 +29,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/availabilitysets/mock_availabilitysets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -77,12 +77,12 @@ func TestReconcileAvailabilitySets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "create or update availability set", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, nil) @@ -91,14 +91,14 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "noop if no availability set spec returns nil", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(nil) }, }, { name: "missing required value in availability set spec", expectedError: "some error with parameters", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpecMissing) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpecMissing, serviceName).Return(nil, parameterError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, parameterError) @@ -107,7 +107,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { { name: "error in creating availability set", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSetSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.AvailabilitySetReadyCondition, serviceName, internalError) @@ -123,7 +123,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_availabilitysets.NewMockAvailabilitySetScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -147,12 +147,12 @@ func TestDeleteAvailabilitySets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "deletes availability set", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(armcompute.AvailabilitySet{}, nil), @@ -164,14 +164,14 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "noop if AvailabilitySetSpec returns nil", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(nil) }, }, { name: "delete proceeds with missing required value in availability set spec", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpecMissing) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpecMissing).Return(armcompute.AvailabilitySet{}, nil), @@ -183,7 +183,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "noop if availability set has vms", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(fakeSetWithVMs, nil), @@ -194,7 +194,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "availability set not found", expectedError: "", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(nil, notFoundError), @@ -205,7 +205,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "error in getting availability set", expectedError: "failed to get availability set test-as in resource group test-rg: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(nil, internalError), @@ -216,7 +216,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "availability set get result is not an availability set", expectedError: "string is not an armcompute.AvailabilitySet", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return("not an availability set", nil), @@ -227,7 +227,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { { name: "error in deleting availability set", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_availabilitysets.MockAvailabilitySetScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AvailabilitySetSpec().Return(&fakeSetSpec) gomock.InOrder( m.Get(gomockinternal.AContext(), &fakeSetSpec).Return(armcompute.AvailabilitySet{}, nil), @@ -246,8 +246,8 @@ func TestDeleteAvailabilitySets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_availabilitysets.NewMockAvailabilitySetScope(mockCtrl) - getterMock := mock_asyncpoller.NewMockGetter(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + getterMock := mock_async.NewMockGetter(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), getterMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/bastionhosts/bastionhosts.go b/azure/services/bastionhosts/bastionhosts.go index 35bda346bda..8d75fb36779 100644 --- a/azure/services/bastionhosts/bastionhosts.go +++ b/azure/services/bastionhosts/bastionhosts.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -39,7 +39,7 @@ type BastionScope interface { // Service provides operations on Azure resources. type Service struct { Scope BastionScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -50,7 +50,7 @@ func New(scope BastionScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.BastionHostsClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.BastionHostsClientCreateOrUpdateResponse, armnetwork.BastionHostsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/bastionhosts/bastionhosts_test.go b/azure/services/bastionhosts/bastionhosts_test.go index b8e58e16743..7634875f3c5 100644 --- a/azure/services/bastionhosts/bastionhosts_test.go +++ b/azure/services/bastionhosts/bastionhosts_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/client-go/kubernetes/scheme" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" mock_bastionhosts "sigs.k8s.io/cluster-api-provider-azure/azure/services/bastionhosts/mocks_bastionhosts" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -53,12 +53,12 @@ func TestReconcileBastionHosts(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "bastion successfully created", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.BastionHostReadyCondition, serviceName, nil) @@ -67,14 +67,14 @@ func TestReconcileBastionHosts(t *testing.T) { { name: "no bastion spec found", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(nil) }, }, { name: "fail to create a bastion", expectedError: internalError.Error(), - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.BastionHostReadyCondition, serviceName, internalError) @@ -90,7 +90,7 @@ func TestReconcileBastionHosts(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_bastionhosts.NewMockBastionScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -114,12 +114,12 @@ func TestDeleteBastionHost(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "successfully delete an existing bastion host", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BastionHostReadyCondition, serviceName, nil) @@ -128,7 +128,7 @@ func TestDeleteBastionHost(t *testing.T) { { name: "bastion host deletion fails", expectedError: internalError.Error(), - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(&fakeAzureBastionSpec) r.DeleteResource(gomockinternal.AContext(), &fakeAzureBastionSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.BastionHostReadyCondition, serviceName, internalError) @@ -137,7 +137,7 @@ func TestDeleteBastionHost(t *testing.T) { { name: "no bastion spec found", expectedError: "", - expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_bastionhosts.MockBastionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.AzureBastionSpec().Return(nil) }, }, @@ -151,7 +151,7 @@ func TestDeleteBastionHost(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_bastionhosts.NewMockBastionScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/bastionhosts/client.go b/azure/services/bastionhosts/client.go index ecf27e8cb12..47cea70c9ed 100644 --- a/azure/services/bastionhosts/client.go +++ b/azure/services/bastionhosts/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/disks/client.go b/azure/services/disks/client.go index 3f75eac1891..420d2cf3e2a 100644 --- a/azure/services/disks/client.go +++ b/azure/services/disks/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -62,7 +62,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/disks/disks.go b/azure/services/disks/disks.go index e74e814b64f..8c9cb6a4d06 100644 --- a/azure/services/disks/disks.go +++ b/azure/services/disks/disks.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -39,7 +39,7 @@ type DiskScope interface { // Service provides operations on Azure resources. type Service struct { Scope DiskScope - asyncpoller.Reconciler + async.Reconciler } // New creates a disks service. @@ -50,7 +50,7 @@ func New(scope DiskScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armcompute.DisksClientCreateOrUpdateResponse, + Reconciler: async.New[armcompute.DisksClientCreateOrUpdateResponse, armcompute.DisksClientDeleteResponse](scope, nil, client), }, nil } diff --git a/azure/services/disks/disks_test.go b/azure/services/disks/disks_test.go index ce1279ecc30..0a1cfc71dd6 100644 --- a/azure/services/disks/disks_test.go +++ b/azure/services/disks/disks_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/disks/mock_disks" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -54,19 +54,19 @@ func TestDeleteDisk(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no disk specs are found", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.DiskSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete the disk", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(nil), @@ -78,7 +78,7 @@ func TestDeleteDisk(t *testing.T) { { name: "disk already deleted", expectedError: "", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(nil), @@ -90,7 +90,7 @@ func TestDeleteDisk(t *testing.T) { { name: "error while trying to delete the disk", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_disks.MockDiskScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.DiskSpecs().Return(fakeDiskSpecs) gomock.InOrder( r.DeleteResource(gomockinternal.AContext(), &diskSpec1, serviceName).Return(internalError), @@ -110,7 +110,7 @@ func TestDeleteDisk(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_disks.NewMockDiskScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/inboundnatrules/client.go b/azure/services/inboundnatrules/client.go index ecefb2bb20d..1bf910508e8 100644 --- a/azure/services/inboundnatrules/client.go +++ b/azure/services/inboundnatrules/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -107,7 +107,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. @@ -136,7 +136,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/inboundnatrules/inboundnatrules.go b/azure/services/inboundnatrules/inboundnatrules.go index b44b847304d..4158dddf8eb 100644 --- a/azure/services/inboundnatrules/inboundnatrules.go +++ b/azure/services/inboundnatrules/inboundnatrules.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -42,7 +42,7 @@ type InboundNatScope interface { type Service struct { Scope InboundNatScope client - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -54,7 +54,7 @@ func New(scope InboundNatScope) (*Service, error) { return &Service{ Scope: scope, client: client, - Reconciler: asyncpoller.New[armnetwork.InboundNatRulesClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.InboundNatRulesClientCreateOrUpdateResponse, armnetwork.InboundNatRulesClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/inboundnatrules/inboundnatrules_test.go b/azure/services/inboundnatrules/inboundnatrules_test.go index 606bb3b426c..44ca569aa63 100644 --- a/azure/services/inboundnatrules/inboundnatrules_test.go +++ b/azure/services/inboundnatrules/inboundnatrules_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/inboundnatrules/mock_inboundnatrules" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -88,14 +88,14 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError string expect func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) + r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no NAT rule specs are found", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{}) @@ -106,7 +106,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) m.List(gomockinternal.AContext(), fakeGroupName, fakeLBName).Return(noExistingRules, nil) @@ -123,7 +123,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") m.List(gomockinternal.AContext(), fakeGroupName, "my-lb").Return(fakeExistingRules, nil) @@ -139,7 +139,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.APIServerLBName().AnyTimes().Return("") }, }, @@ -148,7 +148,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "failed to get existing NAT rules: #: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) @@ -161,7 +161,7 @@ func TestReconcileInboundNATRule(t *testing.T) { expectedError: "#: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, m *mock_inboundnatrules.MockclientMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + r *mock_async.MockReconcilerMockRecorder) { s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return("my-lb") m.List(gomockinternal.AContext(), fakeGroupName, "my-lb").Return(fakeExistingRules, nil) @@ -183,7 +183,7 @@ func TestReconcileInboundNATRule(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_inboundnatrules.NewMockInboundNatScope(mockCtrl) clientMock := mock_inboundnatrules.NewMockclient(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), clientMock.EXPECT(), asyncMock.EXPECT()) @@ -209,13 +209,13 @@ func TestDeleteNetworkInterface(t *testing.T) { name string expectedError string expect func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no NAT rules are found", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{}) }, }, @@ -223,7 +223,7 @@ func TestDeleteNetworkInterface(t *testing.T) { name: "successfully delete an existing NAT rule", expectedError: "", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) @@ -237,7 +237,7 @@ func TestDeleteNetworkInterface(t *testing.T) { name: "NAT rule deletion fails", expectedError: "#: Internal Server Error: StatusCode=500", expect: func(s *mock_inboundnatrules.MockInboundNatScopeMockRecorder, - m *mock_inboundnatrules.MockclientMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_inboundnatrules.MockclientMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.InboundNatSpecs().Return([]azure.ResourceSpecGetter{&fakeNatSpec}) s.ResourceGroup().AnyTimes().Return(fakeGroupName) s.APIServerLBName().AnyTimes().Return(fakeLBName) @@ -258,7 +258,7 @@ func TestDeleteNetworkInterface(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_inboundnatrules.NewMockInboundNatScope(mockCtrl) clientMock := mock_inboundnatrules.NewMockclient(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), clientMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/loadbalancers/client.go b/azure/services/loadbalancers/client.go index a86d187ac23..7d238d6d07c 100644 --- a/azure/services/loadbalancers/client.go +++ b/azure/services/loadbalancers/client.go @@ -24,7 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -104,7 +104,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -132,7 +132,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if error occurs, return the poller. diff --git a/azure/services/loadbalancers/loadbalancers.go b/azure/services/loadbalancers/loadbalancers.go index b9d6cf21954..ce197d1499d 100644 --- a/azure/services/loadbalancers/loadbalancers.go +++ b/azure/services/loadbalancers/loadbalancers.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -45,7 +45,7 @@ type LBScope interface { // Service provides operations on Azure resources. type Service struct { Scope LBScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -56,7 +56,7 @@ func New(scope LBScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.LoadBalancersClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.LoadBalancersClientCreateOrUpdateResponse, armnetwork.LoadBalancersClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/loadbalancers/loadbalancers_test.go b/azure/services/loadbalancers/loadbalancers_test.go index 5c63b0cbcb4..3f67d7b9551 100644 --- a/azure/services/loadbalancers/loadbalancers_test.go +++ b/azure/services/loadbalancers/loadbalancers_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/loadbalancers/mock_loadbalancers" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -108,19 +108,19 @@ func TestReconcileLoadBalancer(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no LBSpecs are found", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "fail to create a public LB", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, internalError) @@ -129,7 +129,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create public apiserver LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -138,7 +138,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create internal apiserver LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakeInternalAPILBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -147,7 +147,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create node outbound LB", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakeNodeOutboundLBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNodeOutboundLBSpec, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -156,7 +156,7 @@ func TestReconcileLoadBalancer(t *testing.T) { { name: "create multiple LBs", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec, &fakeInternalAPILBSpec, &fakeNodeOutboundLBSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil, nil) @@ -176,7 +176,7 @@ func TestReconcileLoadBalancer(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_loadbalancers.NewMockLBScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -199,19 +199,19 @@ func TestDeleteLoadBalancer(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no LBSpecs are found", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete a load balancer", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.LoadBalancersReadyCondition, serviceName, nil) @@ -220,7 +220,7 @@ func TestDeleteLoadBalancer(t *testing.T) { { name: "delete multiple load balancers", expectedError: "", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec, &fakeInternalAPILBSpec, &fakeNodeOutboundLBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeInternalAPILBSpec, serviceName).Return(nil) @@ -231,7 +231,7 @@ func TestDeleteLoadBalancer(t *testing.T) { { name: "load balancer deletion fails", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_loadbalancers.MockLBScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.LBSpecs().Return([]azure.ResourceSpecGetter{&fakePublicAPILBSpec}) r.DeleteResource(gomockinternal.AContext(), &fakePublicAPILBSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.LoadBalancersReadyCondition, serviceName, internalError) @@ -249,7 +249,7 @@ func TestDeleteLoadBalancer(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_loadbalancers.NewMockLBScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/managedclusters/client.go b/azure/services/managedclusters/client.go index c0f78753de9..e64975c63cd 100644 --- a/azure/services/managedclusters/client.go +++ b/azure/services/managedclusters/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -111,7 +111,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. @@ -140,7 +140,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. diff --git a/azure/services/managedclusters/managedclusters.go b/azure/services/managedclusters/managedclusters.go index 51f34df44ae..44a7ce27cb9 100644 --- a/azure/services/managedclusters/managedclusters.go +++ b/azure/services/managedclusters/managedclusters.go @@ -25,7 +25,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -50,7 +50,7 @@ type ManagedClusterScope interface { // Service provides operations on azure resources. type Service struct { Scope ManagedClusterScope - asyncpoller.Reconciler + async.Reconciler CredentialGetter } @@ -62,7 +62,7 @@ func New(scope ManagedClusterScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armcontainerservice.ManagedClustersClientCreateOrUpdateResponse, + Reconciler: async.New[armcontainerservice.ManagedClustersClientCreateOrUpdateResponse, armcontainerservice.ManagedClustersClientDeleteResponse](scope, client, client), CredentialGetter: client, }, nil diff --git a/azure/services/managedclusters/managedclusters_test.go b/azure/services/managedclusters/managedclusters_test.go index 9d665f519ec..52ed19d3657 100644 --- a/azure/services/managedclusters/managedclusters_test.go +++ b/azure/services/managedclusters/managedclusters_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/managedclusters/mock_managedclusters" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -38,19 +38,19 @@ func TestReconcile(t *testing.T) { testcases := []struct { name string expectedError string - expect func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if managedcluster spec is nil", expectedError: "", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(nil) }, }, { name: "create managed cluster returns an error", expectedError: "some unexpected error occurred", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(nil, errors.New("some unexpected error occurred")) s.UpdatePutStatus(infrav1.ManagedClusterRunningCondition, serviceName, errors.New("some unexpected error occurred")) @@ -59,7 +59,7 @@ func TestReconcile(t *testing.T) { { name: "create managed cluster succeeds", expectedError: "", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(armcontainerservice.ManagedCluster{ Properties: &armcontainerservice.ManagedClusterProperties{ @@ -85,7 +85,7 @@ func TestReconcile(t *testing.T) { { name: "fail to get managed cluster credentials", expectedError: "failed to get credentials for managed cluster: internal server error", - expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(m *mock_managedclusters.MockCredentialGetterMockRecorder, s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(armcontainerservice.ManagedCluster{ Properties: &armcontainerservice.ManagedClusterProperties{ @@ -111,7 +111,7 @@ func TestReconcile(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_managedclusters.NewMockManagedClusterScope(mockCtrl) credsGetterMock := mock_managedclusters.NewMockCredentialGetter(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(credsGetterMock.EXPECT(), scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -136,19 +136,19 @@ func TestDelete(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no managed cluster spec is found", expectedError: "", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(nil) }, }, { name: "successfully delete an existing managed cluster", expectedError: "", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.DeleteResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.ManagedClusterRunningCondition, serviceName, nil) @@ -157,7 +157,7 @@ func TestDelete(t *testing.T) { { name: "managed cluster deletion fails", expectedError: "internal error", - expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_managedclusters.MockManagedClusterScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.ManagedClusterSpec().Return(fakeManagedClusterSpec) r.DeleteResource(gomockinternal.AContext(), fakeManagedClusterSpec, serviceName).Return(errors.New("internal error")) s.UpdateDeleteStatus(infrav1.ManagedClusterRunningCondition, serviceName, errors.New("internal error")) @@ -173,7 +173,7 @@ func TestDelete(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_managedclusters.NewMockManagedClusterScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/natgateways/client.go b/azure/services/natgateways/client.go index f0094ff82db..3f3599b0557 100644 --- a/azure/services/natgateways/client.go +++ b/azure/services/natgateways/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -80,7 +80,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -109,7 +109,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/natgateways/natgateways.go b/azure/services/natgateways/natgateways.go index e1b5bf4a34e..ea97fd83328 100644 --- a/azure/services/natgateways/natgateways.go +++ b/azure/services/natgateways/natgateways.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -41,7 +41,7 @@ type NatGatewayScope interface { // Service provides operations on azure resources. type Service struct { Scope NatGatewayScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -52,7 +52,7 @@ func New(scope NatGatewayScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.NatGatewaysClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.NatGatewaysClientCreateOrUpdateResponse, armnetwork.NatGatewaysClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/natgateways/natgateways_test.go b/azure/services/natgateways/natgateways_test.go index c4ddd071287..3ad663b422a 100644 --- a/azure/services/natgateways/natgateways_test.go +++ b/azure/services/natgateways/natgateways_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/natgateways/mock_natgateways" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -69,13 +69,13 @@ func TestReconcileNatGateways(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no NAT gateways specs are found", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -84,7 +84,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "NAT gateways in custom vnet mode", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -92,7 +92,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "NAT gateway create successfully", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(natGateway1, nil) @@ -104,7 +104,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "fail to create a NAT gateway", tags: ownedVNetTags, expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(nil, internalError) @@ -115,7 +115,7 @@ func TestReconcileNatGateways(t *testing.T) { name: "result is not a NAT gateway", tags: ownedVNetTags, expectedError: "created resource string is not an armnetwork.NatGateway", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return("not a nat gateway", nil) @@ -132,7 +132,7 @@ func TestReconcileNatGateways(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_natgateways.NewMockNatGatewayScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -157,13 +157,13 @@ func TestDeleteNatGateway(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no NAT gateways specs are found", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -172,7 +172,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateways in custom vnet mode", tags: customVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -180,7 +180,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateway deleted successfully", tags: ownedVNetTags, expectedError: "", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.DeleteResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(nil) @@ -191,7 +191,7 @@ func TestDeleteNatGateway(t *testing.T) { name: "NAT gateway deletion fails", tags: ownedVNetTags, expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_natgateways.MockNatGatewayScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NatGatewaySpecs().Return([]azure.ResourceSpecGetter{&natGatewaySpec1}) r.DeleteResource(gomockinternal.AContext(), &natGatewaySpec1, serviceName).Return(internalError) @@ -208,7 +208,7 @@ func TestDeleteNatGateway(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_natgateways.NewMockNatGatewayScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/networkinterfaces/client.go b/azure/services/networkinterfaces/client.go index e0165f631f1..dfa156a7cda 100644 --- a/azure/services/networkinterfaces/client.go +++ b/azure/services/networkinterfaces/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/networkinterfaces/networkinterfaces.go b/azure/services/networkinterfaces/networkinterfaces.go index 3b931813d49..bd2a761d2d1 100644 --- a/azure/services/networkinterfaces/networkinterfaces.go +++ b/azure/services/networkinterfaces/networkinterfaces.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -40,7 +40,7 @@ type NICScope interface { // Service provides operations on Azure resources. type Service struct { Scope NICScope - asyncpoller.Reconciler + async.Reconciler resourceSKUCache *resourceskus.Cache } @@ -52,7 +52,7 @@ func New(scope NICScope, skuCache *resourceskus.Cache) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.InterfacesClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.InterfacesClientCreateOrUpdateResponse, armnetwork.InterfacesClientDeleteResponse](scope, client, client), resourceSKUCache: skuCache, }, nil diff --git a/azure/services/networkinterfaces/networkinterfaces_test.go b/azure/services/networkinterfaces/networkinterfaces_test.go index a0dec8f6e35..c16d90831ff 100644 --- a/azure/services/networkinterfaces/networkinterfaces_test.go +++ b/azure/services/networkinterfaces/networkinterfaces_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces/mock_networkinterfaces" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -77,19 +77,19 @@ func TestReconcileNetworkInterface(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no network interface specs are found", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully create a network interface", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -98,7 +98,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "successfully create a network interface with multiple IPConfigs", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec3}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec3, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -107,7 +107,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "successfully create multiple network interfaces", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil, nil) @@ -117,7 +117,7 @@ func TestReconcileNetworkInterface(t *testing.T) { { name: "network interface create fails", expectedError: internalError.Error(), - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil, internalError) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil, nil) @@ -134,7 +134,7 @@ func TestReconcileNetworkInterface(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_networkinterfaces.NewMockNICScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -160,19 +160,19 @@ func TestDeleteNetworkInterface(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no network interface specs are found", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully delete an existing network interface", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.NetworkInterfaceReadyCondition, serviceName, nil) @@ -181,7 +181,7 @@ func TestDeleteNetworkInterface(t *testing.T) { { name: "successfully delete multiple existing network interfaces", expectedError: "", - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(nil) @@ -191,7 +191,7 @@ func TestDeleteNetworkInterface(t *testing.T) { { name: "network interface deletion fails", expectedError: internalError.Error(), - expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_networkinterfaces.MockNICScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.NICSpecs().Return([]azure.ResourceSpecGetter{&fakeNICSpec1, &fakeNICSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec1, serviceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakeNICSpec2, serviceName).Return(internalError) @@ -208,7 +208,7 @@ func TestDeleteNetworkInterface(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_networkinterfaces.NewMockNICScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/privatedns/link_client.go b/azure/services/privatedns/link_client.go index 06e002a0607..84041b69cec 100644 --- a/azure/services/privatedns/link_client.go +++ b/azure/services/privatedns/link_client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (avc *azureVirtualNetworkLinksClient) CreateOrUpdateAsync(ctx context.Conte ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (avc *azureVirtualNetworkLinksClient) DeleteAsync(ctx context.Context, spec ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/privatedns/privatedns.go b/azure/services/privatedns/privatedns.go index 1d3f7af2189..5ebd99fd3c9 100644 --- a/azure/services/privatedns/privatedns.go +++ b/azure/services/privatedns/privatedns.go @@ -24,7 +24,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -43,10 +43,10 @@ type Scope interface { // Service provides operations on Azure resources. type Service struct { Scope Scope - TagsGetter asyncpoller.TagsGetter - zoneReconciler asyncpoller.Reconciler - vnetLinkReconciler asyncpoller.Reconciler - recordReconciler asyncpoller.Reconciler + TagsGetter async.TagsGetter + zoneReconciler async.Reconciler + vnetLinkReconciler async.Reconciler + recordReconciler async.Reconciler } // New creates a new private dns service. @@ -70,11 +70,11 @@ func New(scope Scope) (*Service, error) { return &Service{ Scope: scope, TagsGetter: tagsClient, - zoneReconciler: asyncpoller.New[armprivatedns.PrivateZonesClientCreateOrUpdateResponse, + zoneReconciler: async.New[armprivatedns.PrivateZonesClientCreateOrUpdateResponse, armprivatedns.PrivateZonesClientDeleteResponse](scope, zoneClient, zoneClient), - vnetLinkReconciler: asyncpoller.New[armprivatedns.VirtualNetworkLinksClientCreateOrUpdateResponse, + vnetLinkReconciler: async.New[armprivatedns.VirtualNetworkLinksClientCreateOrUpdateResponse, armprivatedns.VirtualNetworkLinksClientDeleteResponse](scope, vnetLinkClient, vnetLinkClient), - recordReconciler: asyncpoller.New[armprivatedns.RecordSetsClientCreateOrUpdateResponse, + recordReconciler: async.New[armprivatedns.RecordSetsClientCreateOrUpdateResponse, armprivatedns.RecordSetsClientDeleteResponse](scope, recordSetsClient, recordSetsClient), }, nil } diff --git a/azure/services/privatedns/privatedns_test.go b/azure/services/privatedns/privatedns_test.go index 031c4a4f7ae..d7217ea6240 100644 --- a/azure/services/privatedns/privatedns_test.go +++ b/azure/services/privatedns/privatedns_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/privatedns/mock_privatedns" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -98,20 +98,20 @@ func TestReconcilePrivateDNS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_privatedns.MockScopeMockRecorder, zoneReconiler, linksReconciler, recordsReconciler *mock_asyncpoller.MockReconcilerMockRecorder, - tagsGetter *mock_asyncpoller.MockTagsGetterMockRecorder) + expect func(s *mock_privatedns.MockScopeMockRecorder, zoneReconiler, linksReconciler, recordsReconciler *mock_async.MockReconcilerMockRecorder, + tagsGetter *mock_async.MockTagsGetterMockRecorder) }{ { name: "no private dns", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(nil, nil, nil) }, }, { name: "create private dns with multiple links successfully", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -135,7 +135,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "zone creation in progress", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -148,7 +148,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "zone creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -160,7 +160,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "unmanaged zone does not update ready condition", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -183,7 +183,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 1 creation fails but still proceeds to link 2, and returns the error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -205,7 +205,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 2 creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -227,7 +227,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "link 1 is long running, link 2 fails, it returns the failure of link2", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -248,7 +248,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "unmanaged link does not update ready condition", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -270,7 +270,7 @@ func TestReconcilePrivateDNS(t *testing.T) { }, { name: "vnet link is considered managed if at least one of the links is managed", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -294,7 +294,7 @@ func TestReconcilePrivateDNS(t *testing.T) { { name: "record creation fails", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, z, l, r *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -326,10 +326,10 @@ func TestReconcilePrivateDNS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privatedns.NewMockScope(mockCtrl) - zoneReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - vnetLinkReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - recordReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + zoneReconcilerMock := mock_async.NewMockReconciler(mockCtrl) + vnetLinkReconcilerMock := mock_async.NewMockReconciler(mockCtrl) + recordReconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), zoneReconcilerMock.EXPECT(), vnetLinkReconcilerMock.EXPECT(), recordReconcilerMock.EXPECT(), tagsGetterMock.EXPECT()) @@ -356,19 +356,19 @@ func TestDeletePrivateDNS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_privatedns.MockScopeMockRecorder, linkReconciler, zoneReconciler *mock_asyncpoller.MockReconcilerMockRecorder, tagsGetter *mock_asyncpoller.MockTagsGetterMockRecorder) + expect func(s *mock_privatedns.MockScopeMockRecorder, linkReconciler, zoneReconciler *mock_async.MockReconcilerMockRecorder, tagsGetter *mock_async.MockTagsGetterMockRecorder) }{ { name: "no private dns", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(nil, nil, nil) }, }, { name: "dns and links deletion succeeds", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -396,7 +396,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "skips if zone and links are unmanaged", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -415,7 +415,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "skips if unmanaged, but deletes the next resource if it is managed", expectedError: "", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -440,7 +440,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "link1 is deleted, link2 is long running. It returns not done error", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}) s.SubscriptionID().Return("123") @@ -460,7 +460,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "link1 deletion fails and link2 is long running, returns the more pressing error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}) s.SubscriptionID().Return("123") @@ -480,7 +480,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "links are deleted, zone is long running", expectedError: "operation type resourceType on Azure resource my-rg/resourceName is not done", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -509,7 +509,7 @@ func TestDeletePrivateDNS(t *testing.T) { { name: "links are deleted, zone deletion fails with error", expectedError: "this is an error", - expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_asyncpoller.MockReconcilerMockRecorder, tg *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_privatedns.MockScopeMockRecorder, lr, zr *mock_async.MockReconcilerMockRecorder, tg *mock_async.MockTagsGetterMockRecorder) { s.PrivateDNSSpec().Return(fakeZone, []azure.ResourceSpecGetter{fakeLink1, fakeLink2}, []azure.ResourceSpecGetter{fakeRecord1}).Times(2) s.SubscriptionID().Return("123") @@ -546,9 +546,9 @@ func TestDeletePrivateDNS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privatedns.NewMockScope(mockCtrl) - vnetLinkReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - zoneReconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + vnetLinkReconcilerMock := mock_async.NewMockReconciler(mockCtrl) + zoneReconcilerMock := mock_async.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), vnetLinkReconcilerMock.EXPECT(), zoneReconcilerMock.EXPECT(), tagsGetterMock.EXPECT()) diff --git a/azure/services/privatedns/zone_client.go b/azure/services/privatedns/zone_client.go index b876666a858..cd7bc7ab515 100644 --- a/azure/services/privatedns/zone_client.go +++ b/azure/services/privatedns/zone_client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (azc *azureZonesClient) CreateOrUpdateAsync(ctx context.Context, spec azure ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (azc *azureZonesClient) DeleteAsync(ctx context.Context, spec azure.Resourc ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/privateendpoints/client.go b/azure/services/privateendpoints/client.go index 90f68c7e68d..353a4a3102a 100644 --- a/azure/services/privateendpoints/client.go +++ b/azure/services/privateendpoints/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/privateendpoints/privateendpoints.go b/azure/services/privateendpoints/privateendpoints.go index f79dfa18982..7b9345a1ba1 100644 --- a/azure/services/privateendpoints/privateendpoints.go +++ b/azure/services/privateendpoints/privateendpoints.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -40,7 +40,7 @@ type PrivateEndpointScope interface { // Service provides operations on Azure resources. type Service struct { Scope PrivateEndpointScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -51,7 +51,7 @@ func New(scope PrivateEndpointScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.PrivateEndpointsClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.PrivateEndpointsClientCreateOrUpdateResponse, armnetwork.PrivateEndpointsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/privateendpoints/privateendpoints_test.go b/azure/services/privateendpoints/privateendpoints_test.go index 16ef5fe85d8..0509d5d6659 100644 --- a/azure/services/privateendpoints/privateendpoints_test.go +++ b/azure/services/privateendpoints/privateendpoints_test.go @@ -26,7 +26,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/privateendpoints/mock_privateendpoints" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -70,13 +70,13 @@ var ( func TestReconcilePrivateEndpoint(t *testing.T) { testcases := []struct { name string - expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) expectedError string }{ { name: "create a private endpoint with automatic approval", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return([]azure.ResourceSpecGetter{&fakePrivateEndpoint1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -85,7 +85,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "create a private endpoint with manual approval", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[1:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, nil) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -94,7 +94,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "create multiple private endpoints", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, nil) @@ -104,7 +104,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "return error when creating a private endpoint using an empty spec", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[3:]) r.CreateOrUpdateResource(gomockinternal.AContext(), &emptyPrivateEndpointSpec, ServiceName).Return(nil, internalError) p.UpdatePutStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, internalError) @@ -113,7 +113,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "not done error in creating is ignored", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(&fakePrivateEndpoint2, internalError) @@ -124,7 +124,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { { name: "not done error in creating remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(&fakePrivateEndpoint1, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil, notDoneError) @@ -142,7 +142,7 @@ func TestReconcilePrivateEndpoint(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privateendpoints.NewMockPrivateEndpointScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -165,13 +165,13 @@ func TestReconcilePrivateEndpoint(t *testing.T) { func TestDeletePrivateEndpoints(t *testing.T) { testcases := []struct { name string - expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) expectedError string }{ { name: "delete a private endpoint", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:1]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) p.UpdateDeleteStatus(infrav1.PrivateEndpointsReadyCondition, ServiceName, nil) @@ -180,14 +180,14 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "noop if no private endpoints specs are found", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, _ *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, _ *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete multiple private endpoints", expectedError: "", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil) @@ -197,7 +197,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "error in deleting peering", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(internalError) @@ -207,7 +207,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "not done error in deleting is ignored", expectedError: internalError.Error(), - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(internalError) @@ -218,7 +218,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { { name: "not done error in deleting remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_privateendpoints.MockPrivateEndpointScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.PrivateEndpointSpecs().Return(fakePrivateEndpointSpecs[:3]) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint1, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePrivateEndpoint2, ServiceName).Return(nil) @@ -237,7 +237,7 @@ func TestDeletePrivateEndpoints(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_privateendpoints.NewMockPrivateEndpointScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/publicips/client.go b/azure/services/publicips/client.go index d0fc8c968c4..59534848e81 100644 --- a/azure/services/publicips/client.go +++ b/azure/services/publicips/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -80,7 +80,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -108,7 +108,7 @@ func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/publicips/publicips.go b/azure/services/publicips/publicips.go index 69867c1488b..360f04a9d79 100644 --- a/azure/services/publicips/publicips.go +++ b/azure/services/publicips/publicips.go @@ -24,7 +24,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -42,9 +42,9 @@ type PublicIPScope interface { // Service provides operations on Azure resources. type Service struct { Scope PublicIPScope - asyncpoller.Reconciler - asyncpoller.Getter - asyncpoller.TagsGetter + async.Reconciler + async.Getter + async.TagsGetter } // New creates a new service. @@ -61,7 +61,7 @@ func New(scope PublicIPScope) (*Service, error) { Scope: scope, Getter: client, TagsGetter: tagsClient, - Reconciler: asyncpoller.New[armnetwork.PublicIPAddressesClientCreateOrUpdateResponse, armnetwork.PublicIPAddressesClientDeleteResponse](scope, client, client), + Reconciler: async.New[armnetwork.PublicIPAddressesClientCreateOrUpdateResponse, armnetwork.PublicIPAddressesClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/publicips/publicips_test.go b/azure/services/publicips/publicips_test.go index 5cb225ae0a8..d64642131cb 100644 --- a/azure/services/publicips/publicips_test.go +++ b/azure/services/publicips/publicips_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips/mock_publicips" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -119,19 +119,19 @@ func TestReconcilePublicIP(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully create public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec2, serviceName).Return(nil, nil) @@ -143,7 +143,7 @@ func TestReconcilePublicIP(t *testing.T) { { name: "fail to create a public IP", expectedError: internalError.Error(), - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePublicIPSpec2, serviceName).Return(nil, nil) @@ -164,8 +164,8 @@ func TestReconcilePublicIP(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_publicips.NewMockPublicIPScope(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -190,19 +190,19 @@ func TestDeletePublicIP(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "successfully delete managed public IPs and ignore unmanaged public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -230,7 +230,7 @@ func TestDeletePublicIP(t *testing.T) { { name: "noop if no managed public IPs", expectedError: "", - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -253,7 +253,7 @@ func TestDeletePublicIP(t *testing.T) { { name: "fail to delete managed public IP", expectedError: internalError.Error(), - expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_publicips.MockPublicIPScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.PublicIPSpecs().Return([]azure.ResourceSpecGetter{&fakePublicIPSpec1, &fakePublicIPSpec2, &fakePublicIPSpec3, &fakePublicIPSpecIpv6}) s.SubscriptionID().Return("123") @@ -291,8 +291,8 @@ func TestDeletePublicIP(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_publicips.NewMockPublicIPScope(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/roleassignments/roleassignments.go b/azure/services/roleassignments/roleassignments.go index 4eb0e552fd8..aeb00762c94 100644 --- a/azure/services/roleassignments/roleassignments.go +++ b/azure/services/roleassignments/roleassignments.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachines" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -46,9 +46,9 @@ type RoleAssignmentScope interface { // Service provides operations on Azure resources. type Service struct { Scope RoleAssignmentScope - virtualMachinesGetter asyncpoller.Getter - asyncpoller.Reconciler - virtualMachineScaleSetGetter asyncpoller.Getter + virtualMachinesGetter async.Getter + async.Reconciler + virtualMachineScaleSetGetter async.Getter } // New creates a new service. @@ -69,7 +69,7 @@ func New(scope RoleAssignmentScope) (*Service, error) { Scope: scope, virtualMachinesGetter: virtualMachinesClient, virtualMachineScaleSetGetter: scaleSetsClient, - Reconciler: asyncpoller.New[armauthorization.RoleAssignmentsClientCreateResponse, + Reconciler: async.New[armauthorization.RoleAssignmentsClientCreateResponse, armauthorization.RoleAssignmentsClientDeleteResponse](scope, client, nil), }, nil } diff --git a/azure/services/roleassignments/roleassignments_test.go b/azure/services/roleassignments/roleassignments_test.go index f754d13831a..69d0093d2bc 100644 --- a/azure/services/roleassignments/roleassignments_test.go +++ b/azure/services/roleassignments/roleassignments_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/mock/gomock" "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments/mock_roleassignments" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets/mock_scalesets" @@ -65,7 +65,7 @@ var ( func TestReconcileRoleAssignmentsVM(t *testing.T) { testcases := []struct { name string - expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, m *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, m *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) expectedError string }{ { @@ -73,8 +73,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { expectedError: "", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_asyncpoller.MockGetterMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_async.MockGetterMockRecorder, + r *mock_async.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -93,8 +93,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { name: "error getting VM", expectedError: "failed to assign role to system assigned identity: failed to get principal ID for VM: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_asyncpoller.MockGetterMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_async.MockGetterMockRecorder, + r *mock_async.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -107,8 +107,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { name: "return error when creating a role assignment", expectedError: "cannot assign role to VirtualMachine system assigned identity: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - m *mock_asyncpoller.MockGetterMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder) { + m *mock_async.MockGetterMockRecorder, + r *mock_async.MockReconcilerMockRecorder) { s.SubscriptionID().AnyTimes().Return("12345") s.ResourceGroup().Return("my-rg") s.Name().Return(fakeRoleAssignment1.MachineName) @@ -134,8 +134,8 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_roleassignments.NewMockRoleAssignmentScope(mockCtrl) - vmGetterMock := mock_asyncpoller.NewMockGetter(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + vmGetterMock := mock_async.NewMockGetter(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), vmGetterMock.EXPECT(), asyncMock.EXPECT()) @@ -159,7 +159,7 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { func TestReconcileRoleAssignmentsVMSS(t *testing.T) { testcases := []struct { name string - expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, + expect func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) expectedError string }{ @@ -167,7 +167,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "create a role assignment", expectedError: "", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder, + r *mock_async.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.HasSystemAssignedIdentity().Return(true) s.RoleAssignmentSpecs(&fakePrincipalID).Return(fakeRoleAssignmentSpecs[1:2]) @@ -186,7 +186,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "error getting VMSS", expectedError: "failed to assign role to system assigned identity: failed to get principal ID for VMSS: #: Internal Server Error: StatusCode=500", expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder, + r *mock_async.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.RoleAssignmentResourceType().Return(azure.VirtualMachineScaleSet) s.ResourceGroup().Return("my-rg") @@ -200,7 +200,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { name: "return error when creating a role assignment", expectedError: fmt.Sprintf("cannot assign role to %s system assigned identity: #: Internal Server Error: StatusCode=500", azure.VirtualMachineScaleSet), expect: func(s *mock_roleassignments.MockRoleAssignmentScopeMockRecorder, - r *mock_asyncpoller.MockReconcilerMockRecorder, + r *mock_async.MockReconcilerMockRecorder, mvmss *mock_scalesets.MockClientMockRecorder) { s.HasSystemAssignedIdentity().Return(true) s.RoleAssignmentSpecs(&fakePrincipalID).Return(fakeRoleAssignmentSpecs[1:2]) @@ -226,7 +226,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_roleassignments.NewMockRoleAssignmentScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) vmMock := mock_scalesets.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT(), vmMock.EXPECT()) diff --git a/azure/services/routetables/client.go b/azure/services/routetables/client.go index 4ac3266f1f9..c078bea7fab 100644 --- a/azure/services/routetables/client.go +++ b/azure/services/routetables/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/routetables/routetables.go b/azure/services/routetables/routetables.go index 9de15de597c..30de8788532 100644 --- a/azure/services/routetables/routetables.go +++ b/azure/services/routetables/routetables.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -41,7 +41,7 @@ type RouteTableScope interface { // Service provides operations on azure resources. type Service struct { Scope RouteTableScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -52,7 +52,7 @@ func New(scope RouteTableScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.RouteTablesClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.RouteTablesClientCreateOrUpdateResponse, armnetwork.RouteTablesClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/routetables/routetables_test.go b/azure/services/routetables/routetables_test.go index d39f4ebe73a..91fbb9c9203 100644 --- a/azure/services/routetables/routetables_test.go +++ b/azure/services/routetables/routetables_test.go @@ -25,7 +25,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/routetables/mock_routetables" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -55,12 +55,12 @@ func TestReconcileRouteTables(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no route table specs are found", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -68,7 +68,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "create multiple route tables succeeds", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, nil) @@ -79,7 +79,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "first route table create fails", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, errFake) @@ -90,7 +90,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "second route table create not done", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil, errFake) @@ -101,7 +101,7 @@ func TestReconcileRouteTables(t *testing.T) { { name: "noop if vnet is not managed", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -115,7 +115,7 @@ func TestReconcileRouteTables(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_routetables.NewMockRouteTableScope(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -140,12 +140,12 @@ func TestDeleteRouteTable(t *testing.T) { name string tags infrav1.Tags expectedError string - expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no route table specs are found", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -153,7 +153,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "delete multiple route tables succeeds", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(nil) @@ -164,7 +164,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "first route table delete fails", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(errFake) @@ -175,7 +175,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "second route table delete not done", expectedError: errFake.Error(), - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.RouteTableSpecs().Return([]azure.ResourceSpecGetter{&fakeRT, &fakeRT2}) r.DeleteResource(gomockinternal.AContext(), &fakeRT, serviceName).Return(errFake) @@ -186,7 +186,7 @@ func TestDeleteRouteTable(t *testing.T) { { name: "noop if vnet is not managed", expectedError: "", - expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_routetables.MockRouteTableScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -200,7 +200,7 @@ func TestDeleteRouteTable(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_routetables.NewMockRouteTableScope(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/scalesets/client.go b/azure/services/scalesets/client.go index c1f36388835..3cd900cc052 100644 --- a/azure/services/scalesets/client.go +++ b/azure/services/scalesets/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -161,7 +161,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -193,7 +193,7 @@ func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/scalesets/scalesets.go b/azure/services/scalesets/scalesets.go index 9139de38439..a78c3b6c8da 100644 --- a/azure/services/scalesets/scalesets.go +++ b/azure/services/scalesets/scalesets.go @@ -26,7 +26,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" @@ -54,7 +54,7 @@ type ( Scope ScaleSetScope Client resourceSKUCache *resourceskus.Cache - asyncpoller.Reconciler + async.Reconciler } ) @@ -65,7 +65,7 @@ func New(scope ScaleSetScope, skuCache *resourceskus.Cache) (*Service, error) { return nil, err } return &Service{ - Reconciler: asyncpoller.New[armcompute.VirtualMachineScaleSetsClientCreateOrUpdateResponse, + Reconciler: async.New[armcompute.VirtualMachineScaleSetsClientCreateOrUpdateResponse, armcompute.VirtualMachineScaleSetsClientDeleteResponse](scope, client, client), Client: client, Scope: scope, diff --git a/azure/services/scalesets/scalesets_test.go b/azure/services/scalesets/scalesets_test.go index 6b98b3a5207..4e8228d39ee 100644 --- a/azure/services/scalesets/scalesets_test.go +++ b/azure/services/scalesets/scalesets_test.go @@ -30,7 +30,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets/mock_scalesets" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -97,13 +97,13 @@ func TestReconcileVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) + expect func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) expectedError string }{ { name: "update an existing vmss", expectedError: "", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -120,7 +120,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "create a vmss, skip list instances if vmss doesn't exist", expectedError: "", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -136,7 +136,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting existing vmss", expectedError: "failed to get existing VMSS: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -146,7 +146,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to list instances", expectedError: "failed to get existing VMSS instances: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() // Validate spec s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() @@ -158,7 +158,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to create a vmss", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() m.Get(gomockinternal.AContext(), &defaultSpec).Return(&resultVMSS, nil) @@ -172,7 +172,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "failed to reconcile replicas", expectedError: "unable to reconcile VMSS replicas: #: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := getDefaultVMSSSpec() s.ScaleSetSpec(gomockinternal.AContext()).Return(spec).AnyTimes() m.Get(gomockinternal.AContext(), &defaultSpec).Return(&resultVMSS, nil) @@ -187,7 +187,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: less than 2 vCPUs", expectedError: "reconcile error that cannot be recovered occurred: vm size should be bigger or equal to at least 2 vCPUs. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "VM_SIZE_1_CPU" spec.Capacity = 2 @@ -198,7 +198,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: Memory is less than 2Gi", expectedError: "reconcile error that cannot be recovered occurred: vm memory should be bigger or equal to at least 2Gi. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "VM_SIZE_1_MEM" spec.Capacity = 2 @@ -209,7 +209,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: failed to get SKU", expectedError: "failed to get SKU INVALID_VM_SIZE in compute api: reconcile error that cannot be recovered occurred: resource sku with name 'INVALID_VM_SIZE' and category 'virtualMachines' not found in location 'test-location'. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = "INVALID_VM_SIZE" spec.Capacity = 2 @@ -220,7 +220,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk implicitly enabled by data disk, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -236,7 +236,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk explicitly enabled via additional capabilities, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -250,7 +250,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with ultra disk explicitly enabled via additional capabilities, when location not supported", expectedError: "reconcile error that cannot be recovered occurred: vm size VM_SIZE_USSD does not support ultra disks in location test-location. select a different vm size or disable ultra disks. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -269,7 +269,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "validate spec failure: fail to create a vm with diagnostics set to User Managed but empty StorageAccountURI", expectedError: "reconcile error that cannot be recovered occurred: userManaged must be specified when storageAccountType is 'UserManaged'. Object will not be requeued", - expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(g *WithT, s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { spec := newDefaultVMSSSpec() spec.Size = vmSizeUSSD spec.Capacity = 2 @@ -294,7 +294,7 @@ func TestReconcileVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesets.NewMockScaleSetScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) clientMock := mock_scalesets.NewMockClient(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), clientMock.EXPECT()) @@ -328,12 +328,12 @@ func TestDeleteVMSS(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) + expect func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) }{ { name: "successfully delete an existing vmss", expectedError: "", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -346,7 +346,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "successfully delete an existing vmss, fetch call returns error", expectedError: "", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(nil) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -356,7 +356,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "failed to delete an existing vmss", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { + expect: func(s *mock_scalesets.MockScaleSetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, m *mock_scalesets.MockClientMockRecorder) { s.ScaleSetSpec(gomockinternal.AContext()).Return(&defaultSpec).AnyTimes() r.DeleteResource(gomockinternal.AContext(), &defaultSpec, serviceName).Return(internalError) s.UpdateDeleteStatus(infrav1.BootstrapSucceededCondition, serviceName, internalError) @@ -373,7 +373,7 @@ func TestDeleteVMSS(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_scalesets.NewMockScaleSetScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) mockClient := mock_scalesets.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT(), mockClient.EXPECT()) diff --git a/azure/services/scalesetvms/client.go b/azure/services/scalesetvms/client.go index 4c1ac4057bf..e61465e7bfc 100644 --- a/azure/services/scalesetvms/client.go +++ b/azure/services/scalesetvms/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -67,7 +67,7 @@ func (ac *azureClient) Get(ctx context.Context, spec azure.ResourceSpecGetter) ( return resp.VirtualMachineScaleSetVM, nil } -// CreateOrUpdateAsync is a dummy implementation to fulfill the asyncpoller.Reconciler interface. +// CreateOrUpdateAsync is a dummy implementation to fulfill the async.Reconciler interface. func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armcompute.VirtualMachineScaleSetVMsClientUpdateResponse], err error) { _, _, done := tele.StartSpanWithLogger(ctx, "scalesets.AzureClient.CreateOrUpdateAsync") defer done() @@ -91,7 +91,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/scalesetvms/scalesetvms.go b/azure/services/scalesetvms/scalesetvms.go index 6600c764a0f..b6b90f69fbb 100644 --- a/azure/services/scalesetvms/scalesetvms.go +++ b/azure/services/scalesetvms/scalesetvms.go @@ -26,7 +26,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachines" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -47,8 +47,8 @@ type ( // Service provides operations on Azure resources. Service struct { Scope ScaleSetVMScope - asyncpoller.Reconciler - VMReconciler asyncpoller.Reconciler + async.Reconciler + VMReconciler async.Reconciler } ) @@ -63,9 +63,9 @@ func NewService(scope ScaleSetVMScope) (*Service, error) { return nil, err } return &Service{ - Reconciler: asyncpoller.New[armcompute.VirtualMachineScaleSetVMsClientUpdateResponse, + Reconciler: async.New[armcompute.VirtualMachineScaleSetVMsClientUpdateResponse, armcompute.VirtualMachineScaleSetVMsClientDeleteResponse](scope, client, client), - VMReconciler: asyncpoller.New[armcompute.VirtualMachinesClientCreateOrUpdateResponse, + VMReconciler: async.New[armcompute.VirtualMachinesClientCreateOrUpdateResponse, armcompute.VirtualMachinesClientDeleteResponse](scope, vmClient, vmClient), Scope: scope, }, nil diff --git a/azure/services/scalesetvms/scalesetvms_test.go b/azure/services/scalesetvms/scalesetvms_test.go index f63fa2c57ab..8236a8edda5 100644 --- a/azure/services/scalesetvms/scalesetvms_test.go +++ b/azure/services/scalesetvms/scalesetvms_test.go @@ -27,7 +27,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms/mock_scalesetvms" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -69,13 +69,13 @@ var ( func TestReconcileVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) expectedError string }{ { name: "get a uniform vmss vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(uniformScaleSetVM, nil) s.SetVMSSVM(converters.SDKToVMSSVM(uniformScaleSetVM)) @@ -84,7 +84,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "get a vmss flex vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(flexScaleSetVM, nil) s.SetVMSSVM(converters.SDKVMToVMSSVM(flexScaleSetVM, infrav1.FlexibleOrchestrationMode)) @@ -93,7 +93,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "uniform vmss vm doesn't exist yet", expectedError: "instance does not exist yet. Object will be requeued after 30s", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil, nil) }, @@ -101,7 +101,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "vmss flex vm doesn't exist yet", expectedError: "instance does not exist yet. Object will be requeued after 30s", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil, nil) }, @@ -109,7 +109,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting uniform vmss vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil, errInternal) }, @@ -117,7 +117,7 @@ func TestReconcileVMSS(t *testing.T) { { name: "error getting vmss flex vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.CreateOrUpdateResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil, errInternal) }, @@ -133,8 +133,8 @@ func TestReconcileVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesetvms.NewMockScaleSetVMScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - vmAsyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) + vmAsyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), vmAsyncMock.EXPECT()) @@ -158,13 +158,13 @@ func TestReconcileVMSS(t *testing.T) { func TestDeleteVMSS(t *testing.T) { testcases := []struct { name string - expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) expectedError string }{ { name: "delete a uniform vmss vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.DeleteResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(nil) s.SetVMSSVMState(infrav1.Deleted) @@ -173,7 +173,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "delete a vmss flex vm", expectedError: "", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.DeleteResource(gomockinternal.AContext(), flexGetter, serviceName).Return(nil) s.SetVMSSVMState(infrav1.Deleted) @@ -182,7 +182,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "error when deleting a uniform vmss vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(uniformScaleSetVMSpec) r.DeleteResource(gomockinternal.AContext(), uniformScaleSetVMSpec, serviceName).Return(errInternal) s.SetVMSSVMState(infrav1.Deleting) @@ -191,7 +191,7 @@ func TestDeleteVMSS(t *testing.T) { { name: "error when deleting a vmss flex vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder, v *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(g *WithT, s *mock_scalesetvms.MockScaleSetVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder, v *mock_async.MockReconcilerMockRecorder) { s.ScaleSetVMSpec().Return(flexScaleSetVMSpec) v.DeleteResource(gomockinternal.AContext(), flexGetter, serviceName).Return(errInternal) s.SetVMSSVMState(infrav1.Deleting) @@ -208,8 +208,8 @@ func TestDeleteVMSS(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_scalesetvms.NewMockScaleSetVMScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) - vmAsyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) + vmAsyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(g, scopeMock.EXPECT(), asyncMock.EXPECT(), vmAsyncMock.EXPECT()) diff --git a/azure/services/securitygroups/client.go b/azure/services/securitygroups/client.go index a1afdb36c5c..88502b7ca1f 100644 --- a/azure/services/securitygroups/client.go +++ b/azure/services/securitygroups/client.go @@ -24,7 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -101,7 +101,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // If an error occurs, return the poller. @@ -129,7 +129,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/securitygroups/securitygroups.go b/azure/services/securitygroups/securitygroups.go index a5b51e20916..4a07dfabe76 100644 --- a/azure/services/securitygroups/securitygroups.go +++ b/azure/services/securitygroups/securitygroups.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -42,7 +42,7 @@ type NSGScope interface { // Service provides operations on Azure resources. type Service struct { Scope NSGScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -53,7 +53,7 @@ func New(scope NSGScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.SecurityGroupsClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.SecurityGroupsClientCreateOrUpdateResponse, armnetwork.SecurityGroupsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/securitygroups/securitygroups_test.go b/azure/services/securitygroups/securitygroups_test.go index 486a72ae14f..64bc28940cb 100644 --- a/azure/services/securitygroups/securitygroups_test.go +++ b/azure/services/securitygroups/securitygroups_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/securitygroups/mock_securitygroups" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -92,12 +92,12 @@ func TestReconcileSecurityGroups(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "create single security group with single rule succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -108,7 +108,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "create single security group with multiple rules succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&multipleRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{multipleRulesNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description, securityRule2.Name: securityRule2.Description}}).Times(1) @@ -119,7 +119,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "create multiple security groups, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -131,7 +131,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "first security groups create fails, should return error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -143,7 +143,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "first sg create fails, second sg create not done, should return create error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}).Times(1) @@ -155,7 +155,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "security groups create not done, should return not done error", expectedError: notDoneError.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) s.UpdateAnnotationJSON(annotation, map[string]interface{}{fakeNSG.Name: map[string]string{securityRule1.Name: securityRule1.Description}}) @@ -166,7 +166,7 @@ func TestReconcileSecurityGroups(t *testing.T) { { name: "vnet is not managed, should skip reconcile", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -180,7 +180,7 @@ func TestReconcileSecurityGroups(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_securitygroups.NewMockNSGScope(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) @@ -204,12 +204,12 @@ func TestDeleteSecurityGroups(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "delete multiple security groups succeeds, should return no error", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(nil) @@ -220,7 +220,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "first security groups delete fails, should return an error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(errFake) @@ -231,7 +231,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "first security groups delete fails and second security groups create not done, should return an error", expectedError: errFake.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG, &noRulesNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(errFake) @@ -242,7 +242,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "security groups delete not done, should return not done error", expectedError: notDoneError.Error(), - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(true) s.NSGSpecs().Return([]azure.ResourceSpecGetter{&fakeNSG}) r.DeleteResource(gomockinternal.AContext(), &fakeNSG, serviceName).Return(notDoneError) @@ -252,7 +252,7 @@ func TestDeleteSecurityGroups(t *testing.T) { { name: "vnet is not managed, should skip delete", expectedError: "", - expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_securitygroups.MockNSGScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().Return(false) }, }, @@ -266,7 +266,7 @@ func TestDeleteSecurityGroups(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_securitygroups.NewMockNSGScope(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), reconcilerMock.EXPECT()) diff --git a/azure/services/subnets/client.go b/azure/services/subnets/client.go index da666e6fff1..1e258a2f677 100644 --- a/azure/services/subnets/client.go +++ b/azure/services/subnets/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/subnets/subnets.go b/azure/services/subnets/subnets.go index 590b5639c20..a2357239471 100644 --- a/azure/services/subnets/subnets.go +++ b/azure/services/subnets/subnets.go @@ -25,7 +25,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -45,7 +45,7 @@ type SubnetScope interface { // Service provides operations on Azure resources. type Service struct { Scope SubnetScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -56,7 +56,7 @@ func New(scope SubnetScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.SubnetsClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.SubnetsClientCreateOrUpdateResponse, armnetwork.SubnetsClientDeleteResponse](scope, Client, Client), }, nil } diff --git a/azure/services/subnets/subnets_test.go b/azure/services/subnets/subnets_test.go index fdeb70a7086..348edd36d1f 100644 --- a/azure/services/subnets/subnets_test.go +++ b/azure/services/subnets/subnets_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets/mock_subnets" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -205,19 +205,19 @@ func TestReconcileSubnets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no subnet specs are found", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "create subnet", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(fakeSubnet1, nil) @@ -231,7 +231,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create multiple subnets", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(fakeSubnet1, nil) @@ -249,7 +249,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "don't update ready condition when subnet not managed", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpecNotManaged}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpecNotManaged, serviceName).Return(fakeSubnetNotManaged, nil) @@ -262,7 +262,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create ipv6 subnet", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeIpv6SubnetSpec}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeIpv6SubnetSpec, serviceName).Return(fakeIpv6Subnet, nil) @@ -276,7 +276,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create multiple ipv6 subnets", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeIpv6SubnetSpec, &fakeIpv6SubnetSpecCP}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeIpv6SubnetSpec, serviceName).Return(fakeIpv6Subnet, nil) @@ -294,7 +294,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "fail to create subnet", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil, internalError) @@ -305,7 +305,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "create returns a non subnet", expectedError: notASubnetErr.Error(), - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(notASubnet, nil) }, @@ -313,7 +313,7 @@ func TestReconcileSubnets(t *testing.T) { { name: "fail to create subnets", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil, internalError) @@ -336,7 +336,7 @@ func TestReconcileSubnets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_subnets.NewMockSubnetScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -360,12 +360,12 @@ func TestDeleteSubnets(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no subnet specs are found", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{}) }, @@ -373,7 +373,7 @@ func TestDeleteSubnets(t *testing.T) { { name: "subnets deleted successfully", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeSubnetSpec2}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil) @@ -384,7 +384,7 @@ func TestDeleteSubnets(t *testing.T) { { name: "node subnet and controlplane subnet deleted successfully", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1, &fakeCtrlPlaneSubnetSpec}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(nil) @@ -395,14 +395,14 @@ func TestDeleteSubnets(t *testing.T) { { name: "skip delete if vnet is not managed", expectedError: "", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(false) }, }, { name: "fail delete subnet", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_subnets.MockSubnetScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.IsVnetManaged().AnyTimes().Return(true) s.SubnetSpecs().Return([]azure.ResourceSpecGetter{&fakeSubnetSpec1}) r.DeleteResource(gomockinternal.AContext(), &fakeSubnetSpec1, serviceName).Return(internalError) @@ -419,7 +419,7 @@ func TestDeleteSubnets(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_subnets.NewMockSubnetScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/virtualmachines/client.go b/azure/services/virtualmachines/client.go index ee9a31826cd..73d745e382c 100644 --- a/azure/services/virtualmachines/client.go +++ b/azure/services/virtualmachines/client.go @@ -26,7 +26,7 @@ import ( "github.com/pkg/errors" "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -118,7 +118,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -147,7 +147,7 @@ func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/virtualmachines/virtualmachines.go b/azure/services/virtualmachines/virtualmachines.go index e1e20b49c86..ee685a26f1a 100644 --- a/azure/services/virtualmachines/virtualmachines.go +++ b/azure/services/virtualmachines/virtualmachines.go @@ -29,7 +29,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips" @@ -56,9 +56,9 @@ type VMScope interface { // Service provides operations on Azure resources. type Service struct { Scope VMScope - asyncpoller.Reconciler - interfacesGetter asyncpoller.Getter - publicIPsGetter asyncpoller.Getter + async.Reconciler + interfacesGetter async.Getter + publicIPsGetter async.Getter identitiesGetter identities.Client } @@ -85,7 +85,7 @@ func New(scope VMScope) (*Service, error) { interfacesGetter: interfacesSvc, publicIPsGetter: publicIPsSvc, identitiesGetter: identitiesSvc, - Reconciler: asyncpoller.New[armcompute.VirtualMachinesClientCreateOrUpdateResponse, + Reconciler: async.New[armcompute.VirtualMachinesClientCreateOrUpdateResponse, armcompute.VirtualMachinesClientDeleteResponse](scope, Client, Client), }, nil } diff --git a/azure/services/virtualmachines/virtualmachines_test.go b/azure/services/virtualmachines/virtualmachines_test.go index e8870789065..b53ea984d7e 100644 --- a/azure/services/virtualmachines/virtualmachines_test.go +++ b/azure/services/virtualmachines/virtualmachines_test.go @@ -30,7 +30,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities/mock_identities" "sigs.k8s.io/cluster-api-provider-azure/azure/services/networkinterfaces" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips" @@ -123,19 +123,19 @@ func TestReconcileVM(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no vm spec is found", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(nil) }, }, { name: "create vm succeeds", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -151,7 +151,7 @@ func TestReconcileVM(t *testing.T) { { name: "creating vm fails", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, internalError) @@ -161,7 +161,7 @@ func TestReconcileVM(t *testing.T) { { name: "create vm succeeds but failed to get network interfaces", expectedError: "failed to fetch VM addresses: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -174,7 +174,7 @@ func TestReconcileVM(t *testing.T) { { name: "create vm succeeds but failed to get public IPs", expectedError: "failed to fetch VM addresses: #: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_asyncpoller.MockGetterMockRecorder, mpip *mock_asyncpoller.MockGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, mnic *mock_async.MockGetterMockRecorder, mpip *mock_async.MockGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(&fakeVMSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(fakeExistingVM, nil) s.UpdatePutStatus(infrav1.VMRunningCondition, serviceName, nil) @@ -196,9 +196,9 @@ func TestReconcileVM(t *testing.T) { defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - interfaceMock := mock_asyncpoller.NewMockGetter(mockCtrl) - publicIPMock := mock_asyncpoller.NewMockGetter(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + interfaceMock := mock_async.NewMockGetter(mockCtrl) + publicIPMock := mock_async.NewMockGetter(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), interfaceMock.EXPECT(), publicIPMock.EXPECT(), asyncMock.EXPECT()) @@ -224,19 +224,19 @@ func TestDeleteVM(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no vm spec is found", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().Return(nil) }, }, { name: "vm doesn't exist", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil) s.SetVMState(infrav1.Deleted) @@ -246,7 +246,7 @@ func TestDeleteVM(t *testing.T) { { name: "error occurs when deleting vm", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(internalError) s.SetVMState(infrav1.Deleting) @@ -256,7 +256,7 @@ func TestDeleteVM(t *testing.T) { { name: "delete the vm successfully", expectedError: "", - expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualmachines.MockVMScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMSpec().AnyTimes().Return(&fakeVMSpec) r.DeleteResource(gomockinternal.AContext(), &fakeVMSpec, serviceName).Return(nil) s.SetVMState(infrav1.Deleted) @@ -273,7 +273,7 @@ func TestDeleteVM(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -376,7 +376,7 @@ func TestCheckUserAssignedIdentities(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualmachines.NewMockVMScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) identitiesMock := mock_identities.NewMockClient(mockCtrl) tc.expect(scopeMock.EXPECT(), identitiesMock.EXPECT()) diff --git a/azure/services/virtualnetworks/client.go b/azure/services/virtualnetworks/client.go index 173e210ca86..51ba9c59d65 100644 --- a/azure/services/virtualnetworks/client.go +++ b/azure/services/virtualnetworks/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/virtualnetworks/virtualnetworks.go b/azure/services/virtualnetworks/virtualnetworks.go index be49a669a0a..bc4407c3049 100644 --- a/azure/services/virtualnetworks/virtualnetworks.go +++ b/azure/services/virtualnetworks/virtualnetworks.go @@ -25,7 +25,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -47,9 +47,9 @@ type VNetScope interface { // Service provides operations on Azure resources. type Service struct { Scope VNetScope - asyncpoller.Reconciler - asyncpoller.Getter - asyncpoller.TagsGetter + async.Reconciler + async.Getter + async.TagsGetter } // New creates a new service. @@ -66,7 +66,7 @@ func New(scope VNetScope) (*Service, error) { Scope: scope, Getter: client, TagsGetter: tagsClient, - Reconciler: asyncpoller.New[armnetwork.VirtualNetworksClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.VirtualNetworksClientCreateOrUpdateResponse, armnetwork.VirtualNetworksClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/virtualnetworks/virtualnetworks_test.go b/azure/services/virtualnetworks/virtualnetworks_test.go index 5ede5c313aa..28bc7b8e134 100644 --- a/azure/services/virtualnetworks/virtualnetworks_test.go +++ b/azure/services/virtualnetworks/virtualnetworks_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks/mock_virtualnetworks" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -99,19 +99,19 @@ func TestReconcileVnet(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no vnet spec is found", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(nil) }, }, { name: "reconcile when vnet is not managed", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, nil) s.IsVnetManaged().Return(false) @@ -120,7 +120,7 @@ func TestReconcileVnet(t *testing.T) { { name: "create vnet succeeds, should not return an error", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, nil) s.IsVnetManaged().Return(true) @@ -130,7 +130,7 @@ func TestReconcileVnet(t *testing.T) { { name: "create vnet fails, should return an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(nil, internalError) s.IsVnetManaged().Return(true) @@ -140,7 +140,7 @@ func TestReconcileVnet(t *testing.T) { { name: "existing vnet should update subnet CIDR blocks", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakeVNetSpec, serviceName).Return(customVnet, nil) s.Vnet().Return(&infrav1.VnetSpec{}) @@ -160,8 +160,8 @@ func TestReconcileVnet(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -186,19 +186,19 @@ func TestDeleteVnet(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "noop if no vnet spec is found", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Return(nil) }, }, { name: "delete vnet succeeds, should not return an error", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -210,7 +210,7 @@ func TestDeleteVnet(t *testing.T) { { name: "delete vnet fails, should return an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -222,7 +222,7 @@ func TestDeleteVnet(t *testing.T) { { name: "vnet is not managed, do nothing", expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VNetSpec().Times(2).Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(unmanagedTags, nil) @@ -239,8 +239,8 @@ func TestDeleteVnet(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) - reconcilerMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) + reconcilerMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT(), reconcilerMock.EXPECT()) @@ -266,13 +266,13 @@ func TestIsVnetManaged(t *testing.T) { name string expectedError string result bool - expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) + expect func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) }{ { name: "spec is nil", result: false, expectedError: "cannot get vnet to check if it is managed: spec is nil", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { s.VNetSpec().Return(nil) }, }, @@ -280,7 +280,7 @@ func TestIsVnetManaged(t *testing.T) { name: "managed vnet returns true", result: true, expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(managedTags, nil) @@ -291,7 +291,7 @@ func TestIsVnetManaged(t *testing.T) { name: "custom vnet returns false", result: false, expectedError: "", - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(unmanagedTags, nil) @@ -301,7 +301,7 @@ func TestIsVnetManaged(t *testing.T) { { name: "GET fails returns an error", expectedError: internalError.Error(), - expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_asyncpoller.MockTagsGetterMockRecorder) { + expect: func(s *mock_virtualnetworks.MockVNetScopeMockRecorder, m *mock_async.MockTagsGetterMockRecorder) { s.VNetSpec().Return(&fakeVNetSpec) s.SubscriptionID().Return("123") m.GetAtScope(gomockinternal.AContext(), azure.VNetID("123", fakeVNetSpec.ResourceGroupName(), fakeVNetSpec.Name)).Return(armresources.TagsResource{}, internalError) @@ -317,7 +317,7 @@ func TestIsVnetManaged(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_virtualnetworks.NewMockVNetScope(mockCtrl) - tagsGetterMock := mock_asyncpoller.NewMockTagsGetter(mockCtrl) + tagsGetterMock := mock_async.NewMockTagsGetter(mockCtrl) tc.expect(scopeMock.EXPECT(), tagsGetterMock.EXPECT()) diff --git a/azure/services/vmextensions/client.go b/azure/services/vmextensions/client.go index f8c664d3ba0..7f43308b5ea 100644 --- a/azure/services/vmextensions/client.go +++ b/azure/services/vmextensions/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the Poller. diff --git a/azure/services/vmextensions/vmextensions.go b/azure/services/vmextensions/vmextensions.go index 0c76d706741..90fc4b350ab 100644 --- a/azure/services/vmextensions/vmextensions.go +++ b/azure/services/vmextensions/vmextensions.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -40,7 +40,7 @@ type VMExtensionScope interface { // Service provides operations on Azure resources. type Service struct { Scope VMExtensionScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new vm extension service. @@ -51,7 +51,7 @@ func New(scope VMExtensionScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armcompute.VirtualMachineExtensionsClientCreateOrUpdateResponse, + Reconciler: async.New[armcompute.VirtualMachineExtensionsClientCreateOrUpdateResponse, armcompute.VirtualMachineExtensionsClientDeleteResponse](scope, client, client), }, nil } diff --git a/azure/services/vmextensions/vmextensions_test.go b/azure/services/vmextensions/vmextensions_test.go index c4f97af7312..7297bd87141 100644 --- a/azure/services/vmextensions/vmextensions_test.go +++ b/azure/services/vmextensions/vmextensions_test.go @@ -27,7 +27,7 @@ import ( "go.uber.org/mock/gomock" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vmextensions/mock_vmextensions" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -66,12 +66,12 @@ func TestReconcileVMExtension(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "extension is in succeeded state", expectedError: "", - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, nil) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, nil) @@ -80,7 +80,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "extension is in failed state", expectedError: extensionFailedError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, internalError) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, gomockinternal.ErrStrEq(extensionFailedError.Error())) @@ -89,7 +89,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "extension is still creating", expectedError: extensionNotDoneError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, notDoneError) s.UpdatePutStatus(infrav1.BootstrapSucceededCondition, serviceName, gomockinternal.ErrStrEq(extensionNotDoneError.Error())) @@ -98,7 +98,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "reconcile multiple extensions", expectedError: "", - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1, &extensionSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec2, serviceName).Return(nil, nil) @@ -108,7 +108,7 @@ func TestReconcileVMExtension(t *testing.T) { { name: "error creating the first extension", expectedError: extensionFailedError.Error(), - expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(s *mock_vmextensions.MockVMExtensionScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { s.VMExtensionSpecs().Return([]azure.ResourceSpecGetter{&extensionSpec1, &extensionSpec2}) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec1, serviceName).Return(nil, internalError) r.CreateOrUpdateResource(gomockinternal.AContext(), &extensionSpec2, serviceName).Return(nil, nil) @@ -125,7 +125,7 @@ func TestReconcileVMExtension(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vmextensions.NewMockVMExtensionScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) diff --git a/azure/services/vnetpeerings/client.go b/azure/services/vnetpeerings/client.go index 21e401076b1..32a799bd0ac 100644 --- a/azure/services/vnetpeerings/client.go +++ b/azure/services/vnetpeerings/client.go @@ -23,7 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -79,7 +79,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} resp, err := poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. @@ -107,7 +107,7 @@ func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout) defer cancel() - pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency} + pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency} _, err = poller.PollUntilDone(ctx, pollOpts) if err != nil { // if an error occurs, return the poller. diff --git a/azure/services/vnetpeerings/vnetpeerings.go b/azure/services/vnetpeerings/vnetpeerings.go index 3dc7ab3f652..3d156d75ab9 100644 --- a/azure/services/vnetpeerings/vnetpeerings.go +++ b/azure/services/vnetpeerings/vnetpeerings.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -40,7 +40,7 @@ type VnetPeeringScope interface { // Service provides operations on Azure resources. type Service struct { Scope VnetPeeringScope - asyncpoller.Reconciler + async.Reconciler } // New creates a new service. @@ -51,7 +51,7 @@ func New(scope VnetPeeringScope) (*Service, error) { } return &Service{ Scope: scope, - Reconciler: asyncpoller.New[armnetwork.VirtualNetworkPeeringsClientCreateOrUpdateResponse, + Reconciler: async.New[armnetwork.VirtualNetworkPeeringsClientCreateOrUpdateResponse, armnetwork.VirtualNetworkPeeringsClientDeleteResponse](scope, Client, Client), }, nil } diff --git a/azure/services/vnetpeerings/vnetpeerings_test.go b/azure/services/vnetpeerings/vnetpeerings_test.go index f995214381a..b437c0eb8d0 100644 --- a/azure/services/vnetpeerings/vnetpeerings_test.go +++ b/azure/services/vnetpeerings/vnetpeerings_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller/mock_asyncpoller" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings/mock_vnetpeerings" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" ) @@ -108,12 +108,12 @@ func TestReconcileVnetPeerings(t *testing.T) { testcases := []struct { name string expectedError string - expect func(s *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(s *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "create one peering", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:1]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) p.UpdatePutStatus(infrav1.VnetPeeringReadyCondition, ServiceName, nil) @@ -122,14 +122,14 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "noop if no peering specs are found", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "create even number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:2]) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -139,7 +139,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "create odd number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringExtraSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -150,7 +150,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "create multiple peerings on one vnet", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -164,7 +164,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "error in creating peering", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -178,7 +178,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating is ignored", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil, internalError) @@ -192,7 +192,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating is overwritten", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -206,7 +206,7 @@ func TestReconcileVnetPeerings(t *testing.T) { { name: "not done error in creating remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(&fakePeering1To2, nil) r.CreateOrUpdateResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(&fakePeering2To1, nil) @@ -228,7 +228,7 @@ func TestReconcileVnetPeerings(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vnetpeerings.NewMockVnetPeeringScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT()) @@ -252,12 +252,12 @@ func TestDeleteVnetPeerings(t *testing.T) { testcases := []struct { name string expectedError string - expect func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) + expect func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) }{ { name: "delete one peering", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:1]) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) p.UpdateDeleteStatus(infrav1.VnetPeeringReadyCondition, ServiceName, nil) @@ -266,14 +266,14 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "noop if no peering specs are found", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return([]azure.ResourceSpecGetter{}) }, }, { name: "delete even number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs[:2]) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -283,7 +283,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "delete odd number of peerings", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringExtraSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -294,7 +294,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "delete multiple peerings on one vnet", expectedError: "", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -308,7 +308,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "error in deleting peering", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -322,7 +322,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting is ignored", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(internalError) @@ -336,7 +336,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting is overwritten", expectedError: "#: Internal Server Error: StatusCode=500", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -350,7 +350,7 @@ func TestDeleteVnetPeerings(t *testing.T) { { name: "not done error in deleting remains", expectedError: "operation type on Azure resource / is not done", - expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_asyncpoller.MockReconcilerMockRecorder) { + expect: func(p *mock_vnetpeerings.MockVnetPeeringScopeMockRecorder, r *mock_async.MockReconcilerMockRecorder) { p.VnetPeeringSpecs().Return(fakePeeringSpecs) r.DeleteResource(gomockinternal.AContext(), &fakePeering1To2, ServiceName).Return(nil) r.DeleteResource(gomockinternal.AContext(), &fakePeering2To1, ServiceName).Return(nil) @@ -372,7 +372,7 @@ func TestDeleteVnetPeerings(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() scopeMock := mock_vnetpeerings.NewMockVnetPeeringScope(mockCtrl) - asyncMock := mock_asyncpoller.NewMockReconciler(mockCtrl) + asyncMock := mock_async.NewMockReconciler(mockCtrl) tc.expect(scopeMock.EXPECT(), asyncMock.EXPECT())