-
Notifications
You must be signed in to change notification settings - Fork 414
/
interfaces.go
164 lines (145 loc) · 5.96 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package azure
import (
"context"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// Reconciler is a generic interface for a controller reconciler which has Reconcile and Delete methods.
type Reconciler interface {
Reconcile(ctx context.Context) error
Delete(ctx context.Context) error
}
// Pauser may be implemented for a ServiceReconciler that requires additional work to stop reconciliation.
type Pauser interface {
Pause(context.Context) error
}
// ServiceReconciler is an Azure service reconciler which can reconcile an Azure service.
type ServiceReconciler interface {
Name() string
Reconciler
}
// Authorizer is an interface which can get details such as subscription ID, base URI, and token
// for authorizing to an Azure service.
type Authorizer interface {
SubscriptionID() string
ClientID() string
ClientSecret() string
CloudEnvironment() string
TenantID() string
BaseURI() string
HashKey() string
Token() azcore.TokenCredential
}
// NetworkDescriber is an interface which can get common Azure Cluster Networking information.
type NetworkDescriber interface {
Vnet() *infrav1.VnetSpec
IsVnetManaged() bool
ControlPlaneSubnet() infrav1.SubnetSpec
Subnets() infrav1.Subnets
Subnet(string) infrav1.SubnetSpec
NodeSubnets() []infrav1.SubnetSpec
SetSubnet(infrav1.SubnetSpec)
IsIPv6Enabled() bool
ControlPlaneRouteTable() infrav1.RouteTable
APIServerLB() *infrav1.LoadBalancerSpec
APIServerLBName() string
APIServerLBPoolName() string
IsAPIServerPrivate() bool
GetPrivateDNSZoneName() string
OutboundLBName(string) string
OutboundPoolName(string) string
}
// ClusterDescriber is an interface which can get common Azure Cluster information.
type ClusterDescriber interface {
Authorizer
ResourceGroup() string
NodeResourceGroup() string
ClusterName() string
Location() string
ExtendedLocation() *infrav1.ExtendedLocationSpec
ExtendedLocationName() string
ExtendedLocationType() string
AdditionalTags() infrav1.Tags
AvailabilitySetEnabled() bool
CloudProviderConfigOverrides() *infrav1.CloudProviderConfigOverrides
FailureDomains() []*string
}
// AsyncStatusUpdater is an interface used to keep track of long running operations in Status that has Conditions and Futures.
type AsyncStatusUpdater interface {
SetLongRunningOperationState(*infrav1.Future)
GetLongRunningOperationState(string, string, string) *infrav1.Future
DeleteLongRunningOperationState(string, string, string)
UpdatePutStatus(clusterv1.ConditionType, string, error)
UpdateDeleteStatus(clusterv1.ConditionType, string, error)
UpdatePatchStatus(clusterv1.ConditionType, string, error)
AsyncReconciler
}
// AsyncReconciler is an interface used to get the default timeouts and requeue time for a reconciler that reconciles services asynchronously.
type AsyncReconciler interface {
DefaultedAzureCallTimeout() time.Duration
DefaultedAzureServiceReconcileTimeout() time.Duration
DefaultedReconcilerRequeue() time.Duration
}
// ClusterScoper combines the ClusterDescriber and NetworkDescriber interfaces.
type ClusterScoper interface {
ClusterDescriber
NetworkDescriber
AsyncStatusUpdater
GetClient() client.Client
GetDeletionTimestamp() *metav1.Time
}
// ManagedClusterScoper defines the interface for ManagedClusterScope.
type ManagedClusterScoper interface {
ClusterDescriber
NodeResourceGroup() string
AsyncReconciler
}
// ResourceSpecGetter is an interface for getting all the required information to create/update/delete an Azure resource.
type ResourceSpecGetter interface {
// ResourceName returns the name of the resource.
ResourceName() string
// OwnerResourceName returns the name of the resource that owns the resource
// in the case that the resource is an Azure subresource.
OwnerResourceName() string
// ResourceGroupName returns the name of the resource group the resource is in.
ResourceGroupName() string
// Parameters takes the existing resource and returns the desired parameters of the resource.
// If the resource does not exist, or we do not care about existing parameters to update the resource, existing should be nil.
// If no update is needed on the resource, Parameters should return nil.
Parameters(ctx context.Context, existing interface{}) (params interface{}, err error)
}
// ResourceSpecGetterWithHeaders is a ResourceSpecGetter that can return custom headers to be added to API calls.
type ResourceSpecGetterWithHeaders interface {
ResourceSpecGetter
// CustomHeaders returns the headers that should be added to Azure API calls.
CustomHeaders() map[string]string
}
// ASOResourceSpecGetter is an interface for getting all the required information to create/update/delete an Azure resource.
type ASOResourceSpecGetter[T genruntime.MetaObject] interface {
// ResourceRef returns a concrete, named (and namespaced if applicable) ASO
// resource type to facilitate a strongly-typed GET.
ResourceRef() T
// Parameters returns a modified object if it points to a non-nil resource.
// Otherwise it returns an unmodified object if no updates are needed.
Parameters(ctx context.Context, existing T) (T, error)
// WasManaged returns whether or not the given resource was managed by a
// non-ASO-backed CAPZ and should be considered eligible for adoption.
WasManaged(T) bool
}