-
Notifications
You must be signed in to change notification settings - Fork 414
/
interfaces.go
126 lines (110 loc) · 4.39 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
/*
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"
"github.com/Azure/go-autorest/autorest"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
// 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
}
// ServiceReconciler is an Azure service reconciler which can reconcile an Azure service.
type ServiceReconciler interface {
Name() string
IsManaged(ctx context.Context) (bool, error)
Reconciler
}
// Authorizer is an interface which can get the subscription ID, base URI, and authorizer for an Azure service.
type Authorizer interface {
SubscriptionID() string
ClientID() string
ClientSecret() string
CloudEnvironment() string
TenantID() string
BaseURI() string
Authorizer() autorest.Authorizer
HashKey() string
}
// 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) 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
ClusterName() string
Location() 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)
}
// ClusterScoper combines the ClusterDescriber and NetworkDescriber interfaces.
type ClusterScoper interface {
ClusterDescriber
NetworkDescriber
}
// ManagedClusterScoper defines the interface for ManagedClusterScope.
type ManagedClusterScoper interface {
ClusterDescriber
NodeResourceGroup() string
}
// 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(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
}