Skip to content

Commit f261d6e

Browse files
authored
Merge pull request #4000 from mboersma/sdk-v2-async-cleanup
Rename "asyncpoller" package to "async"
2 parents 09c96a7 + e5e60ff commit f261d6e

File tree

53 files changed

+456
-1734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+456
-1734
lines changed

azure/services/agentpools/agentpools.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"k8s.io/utils/ptr"
2525
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
2626
"sigs.k8s.io/cluster-api-provider-azure/azure"
27-
"sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller"
27+
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async"
2828
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
2929
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3030
)
@@ -52,7 +52,7 @@ type AgentPoolScope interface {
5252
// Service provides operations on Azure resources.
5353
type Service struct {
5454
scope AgentPoolScope
55-
asyncpoller.Reconciler
55+
async.Reconciler
5656
}
5757

5858
// New creates a new service.
@@ -63,7 +63,7 @@ func New(scope AgentPoolScope) (*Service, error) {
6363
}
6464
return &Service{
6565
scope: scope,
66-
Reconciler: asyncpoller.New[armcontainerservice.AgentPoolsClientCreateOrUpdateResponse,
66+
Reconciler: async.New[armcontainerservice.AgentPoolsClientCreateOrUpdateResponse,
6767
armcontainerservice.AgentPoolsClientDeleteResponse](scope, client, client),
6868
}, nil
6969
}

azure/services/agentpools/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
2424
"github.com/pkg/errors"
2525
"sigs.k8s.io/cluster-api-provider-azure/azure"
26-
"sigs.k8s.io/cluster-api-provider-azure/azure/services/asyncpoller"
26+
"sigs.k8s.io/cluster-api-provider-azure/azure/services/async"
2727
"sigs.k8s.io/cluster-api-provider-azure/util/reconciler"
2828
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
2929
)
@@ -89,7 +89,7 @@ func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou
8989
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout)
9090
defer cancel()
9191

92-
pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency}
92+
pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency}
9393
resp, err := poller.PollUntilDone(ctx, pollOpts)
9494
if err != nil {
9595
// If an error occurs, return the poller.
@@ -118,7 +118,7 @@ func (ac *azureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecG
118118
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureCallTimeout)
119119
defer cancel()
120120

121-
pollOpts := &runtime.PollUntilDoneOptions{Frequency: asyncpoller.DefaultPollerFrequency}
121+
pollOpts := &runtime.PollUntilDoneOptions{Frequency: async.DefaultPollerFrequency}
122122
_, err = poller.PollUntilDone(ctx, pollOpts)
123123
if err != nil {
124124
// If an error occurs, return the poller.

azure/services/async/async.go

Lines changed: 105 additions & 150 deletions
Large diffs are not rendered by default.

azure/services/async/async_test.go

Lines changed: 179 additions & 395 deletions
Large diffs are not rendered by default.

azure/services/async/interfaces.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2021 The Kubernetes Authors.
2+
Copyright 2023 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -19,25 +19,17 @@ package async
1919
import (
2020
"context"
2121

22+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
2223
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
23-
azureautorest "github.com/Azure/go-autorest/autorest/azure"
2424
"sigs.k8s.io/cluster-api-provider-azure/azure"
2525
)
2626

27-
// FutureScope is a scope that can perform store futures and conditions in Status.
27+
// FutureScope stores and retrieves Futures and Conditions.
2828
type FutureScope interface {
2929
azure.AsyncStatusUpdater
3030
}
3131

32-
// FutureHandler is a client that can check on the progress of a future.
33-
type FutureHandler interface {
34-
// IsDone returns true if the operation is complete.
35-
IsDone(ctx context.Context, future azureautorest.FutureAPI) (isDone bool, err error)
36-
// Result returns the result of the operation.
37-
Result(ctx context.Context, future azureautorest.FutureAPI, futureType string) (result interface{}, err error)
38-
}
39-
40-
// Getter is an interface that can get a resource.
32+
// Getter gets a resource.
4133
type Getter interface {
4234
Get(ctx context.Context, spec azure.ResourceSpecGetter) (result interface{}, err error)
4335
}
@@ -47,20 +39,18 @@ type TagsGetter interface {
4739
GetAtScope(ctx context.Context, scope string) (result armresources.TagsResource, err error)
4840
}
4941

50-
// Creator is a client that can create or update a resource asynchronously.
51-
type Creator interface {
52-
FutureHandler
42+
// Creator creates or updates a resource asynchronously.
43+
type Creator[T any] interface {
5344
Getter
54-
CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, parameters interface{}) (result interface{}, future azureautorest.FutureAPI, err error)
45+
CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[T], err error)
5546
}
5647

57-
// Deleter is a client that can delete a resource asynchronously.
58-
type Deleter interface {
59-
FutureHandler
60-
DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter) (future azureautorest.FutureAPI, err error)
48+
// Deleter deletes a resource asynchronously.
49+
type Deleter[T any] interface {
50+
DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string) (poller *runtime.Poller[T], err error)
6151
}
6252

63-
// Reconciler is a generic interface used to perform asynchronous reconciliation of Azure resources.
53+
// Reconciler reconciles a resource.
6454
type Reconciler interface {
6555
CreateOrUpdateResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (result interface{}, err error)
6656
DeleteResource(ctx context.Context, spec azure.ResourceSpecGetter, serviceName string) (err error)

0 commit comments

Comments
 (0)