Skip to content

Commit 2075610

Browse files
authored
Merge pull request #2645 from Nordix/lentzi90/capi-imports
🌱 Unify and enforce CAPI import aliases
2 parents 3213ad2 + 16a40e9 commit 2075610

16 files changed

+109
-101
lines changed

.golangci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,18 @@ linters-settings:
110110
alias: clusterv1alpha3
111111
- pkg: sigs.k8s.io/cluster-api/api/v1alpha4
112112
alias: clusterv1alpha4
113-
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
114-
alias: clusterv1b1
115113
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta2
116114
alias: clusterv1
115+
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
116+
alias: clusterv1beta1
117+
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions
118+
alias: v1beta1conditions
119+
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2
120+
alias: deprecatedv1beta2conditions
121+
- pkg: sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1
122+
alias: deprecatedv1beta1conditions
123+
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch
124+
alias: v1beta1patch
117125
- pkg: sigs.k8s.io/cluster-api/api/ipam/v1beta2
118126
alias: ipamv1
119127
# CABPK

api/v1alpha1/openstackfloatingippool_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121

2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
23+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2424

2525
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
2626
)
@@ -88,7 +88,7 @@ type OpenStackFloatingIPPoolStatus struct {
8888
// +optional
8989
FloatingIPNetwork *infrav1.NetworkStatus `json:"floatingIPNetwork,omitempty"`
9090

91-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
91+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
9292
}
9393

9494
//+kubebuilder:object:root=true
@@ -114,12 +114,12 @@ type OpenStackFloatingIPPoolList struct {
114114
}
115115

116116
// GetConditions returns the observations of the operational state of the OpenStackFloatingIPPool resource.
117-
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1.Conditions {
117+
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1beta1.Conditions {
118118
return r.Status.Conditions
119119
}
120120

121121
// SetConditions sets the underlying service state of the OpenStackFloatingIPPool to the predescribed clusterv1.Conditions.
122-
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1.Conditions) {
122+
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1beta1.Conditions) {
123123
r.Status.Conditions = conditions
124124
}
125125

api/v1alpha1/openstackserver_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2323
runtime "k8s.io/apimachinery/pkg/runtime"
24-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
24+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2525

2626
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
2727
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
@@ -153,7 +153,7 @@ type OpenStackServerStatus struct {
153153

154154
// Conditions defines current service state of the OpenStackServer.
155155
// +optional
156-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
156+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
157157
}
158158

159159
// +genclient
@@ -185,12 +185,12 @@ type OpenStackServerList struct {
185185
}
186186

187187
// GetConditions returns the observations of the operational state of the OpenStackServer resource.
188-
func (r *OpenStackServer) GetConditions() clusterv1.Conditions {
188+
func (r *OpenStackServer) GetConditions() clusterv1beta1.Conditions {
189189
return r.Status.Conditions
190190
}
191191

192192
// SetConditions sets the underlying service state of the OpenStackServer to the predescribed clusterv1.Conditions.
193-
func (r *OpenStackServer) SetConditions(conditions clusterv1.Conditions) {
193+
func (r *OpenStackServer) SetConditions(conditions clusterv1beta1.Conditions) {
194194
r.Status.Conditions = conditions
195195
}
196196

api/v1beta1/conditions_consts.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ limitations under the License.
1616

1717
package v1beta1
1818

19-
import clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
19+
import clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2020

2121
const (
2222
// InstanceReadyCondition reports on current status of the OpenStack instance. Ready indicates the instance is in a Running state.
23-
InstanceReadyCondition clusterv1.ConditionType = "InstanceReady"
23+
InstanceReadyCondition clusterv1beta1.ConditionType = "InstanceReady"
2424

2525
// WaitingForClusterInfrastructureReason used when machine is waiting for cluster infrastructure to be ready before proceeding.
2626
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"
@@ -51,7 +51,7 @@ const (
5151

5252
const (
5353
// APIServerIngressReadyCondition reports on the current status of the network ingress (Loadbalancer, Floating IP) for Control Plane machines. Ready indicates that the instance can receive requests.
54-
APIServerIngressReadyCondition clusterv1.ConditionType = "APIServerIngressReadyCondition"
54+
APIServerIngressReadyCondition clusterv1beta1.ConditionType = "APIServerIngressReadyCondition"
5555

5656
// LoadBalancerMemberErrorReason used when the instance could not be added as a loadbalancer member.
5757
LoadBalancerMemberErrorReason = "LoadBalancerMemberError"
@@ -61,7 +61,7 @@ const (
6161

6262
const (
6363
// FloatingAddressFromPoolReadyCondition reports on the current status of the Floating IPs from ipam pool.
64-
FloatingAddressFromPoolReadyCondition clusterv1.ConditionType = "FloatingAddressFromPoolReady"
64+
FloatingAddressFromPoolReadyCondition clusterv1beta1.ConditionType = "FloatingAddressFromPoolReady"
6565
// WaitingForIpamProviderReason used when machine is waiting for ipam provider to be ready before proceeding.
6666
FloatingAddressFromPoolWaitingForIpamProviderReason = "WaitingForIPAMProvider"
6767
// FloatingAddressFromPoolErrorReason is used when there is an error attaching an IP from the pool to an machine.

api/v1beta1/openstackcluster_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package v1beta1
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
21+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2222

2323
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2424
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
@@ -166,7 +166,7 @@ type OpenStackClusterSpec struct {
166166
// values set elsewhere.
167167
// ControlPlaneEndpoint cannot be modified after ControlPlaneEndpoint.Host has been set.
168168
// +optional
169-
ControlPlaneEndpoint *clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
169+
ControlPlaneEndpoint *clusterv1beta1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
170170

171171
// ControlPlaneAvailabilityZones is the set of availability zones which
172172
// control plane machines may be deployed to.
@@ -219,7 +219,7 @@ type OpenStackClusterStatus struct {
219219
APIServerLoadBalancer *LoadBalancer `json:"apiServerLoadBalancer,omitempty"`
220220

221221
// FailureDomains represent OpenStack availability zones
222-
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
222+
FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"`
223223

224224
// ControlPlaneSecurityGroup contains the information about the
225225
// OpenStack Security Group that needs to be applied to control plane

api/v1beta1/openstackmachine_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/utils/ptr"
23-
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
23+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
2424

2525
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
2626
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional"
@@ -234,7 +234,7 @@ type OpenStackMachineStatus struct {
234234
// +optional
235235
FailureMessage *string `json:"failureMessage,omitempty"`
236236

237-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
237+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
238238
}
239239

240240
// +genclient
@@ -267,12 +267,12 @@ type OpenStackMachineList struct {
267267
}
268268

269269
// GetConditions returns the observations of the operational state of the OpenStackMachine resource.
270-
func (r *OpenStackMachine) GetConditions() clusterv1.Conditions {
270+
func (r *OpenStackMachine) GetConditions() clusterv1beta1.Conditions {
271271
return r.Status.Conditions
272272
}
273273

274274
// SetConditions sets the underlying service state of the OpenStackMachine to the predescribed clusterv1.Conditions.
275-
func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
275+
func (r *OpenStackMachine) SetConditions(conditions clusterv1beta1.Conditions) {
276276
r.Status.Conditions = conditions
277277
}
278278

controllers/openstackcluster_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
kerrors "k8s.io/apimachinery/pkg/util/errors"
3333
"k8s.io/client-go/tools/record"
3434
"k8s.io/utils/ptr"
35-
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
35+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3636
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3737
"sigs.k8s.io/cluster-api/util"
3838
"sigs.k8s.io/cluster-api/util/annotations"
@@ -336,7 +336,7 @@ func (r *OpenStackClusterReconciler) reconcileNormal(ctx context.Context, scope
336336
}
337337

338338
// Create a new list in case any AZs have been removed from OpenStack
339-
openStackCluster.Status.FailureDomains = make(clusterv1b1.FailureDomains)
339+
openStackCluster.Status.FailureDomains = make(clusterv1beta1.FailureDomains)
340340
for _, az := range availabilityZones {
341341
// By default, the AZ is used or not used for control plane nodes depending on the flag
342342
found := !ptr.Deref(openStackCluster.Spec.ControlPlaneOmitAvailabilityZone, false)
@@ -346,7 +346,7 @@ func (r *OpenStackClusterReconciler) reconcileNormal(ctx context.Context, scope
346346
}
347347
// Add the AZ object to the failure domains for the cluster
348348

349-
openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1b1.FailureDomainSpec{
349+
openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1beta1.FailureDomainSpec{
350350
ControlPlane: found,
351351
}
352352
}
@@ -873,7 +873,7 @@ func reconcileControlPlaneEndpoint(scope *scope.WithLogger, networkingService *n
873873
return err
874874
}
875875

876-
openStackCluster.Spec.ControlPlaneEndpoint = &clusterv1b1.APIEndpoint{
876+
openStackCluster.Spec.ControlPlaneEndpoint = &clusterv1beta1.APIEndpoint{
877877
Host: host,
878878
Port: apiServerPort,
879879
}

controllers/openstackcluster_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/types"
3333
"k8s.io/utils/ptr"
34-
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
34+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3535
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3636
"sigs.k8s.io/cluster-api/test/framework"
3737
"sigs.k8s.io/cluster-api/util/annotations"
@@ -616,7 +616,7 @@ func Test_getAPIServerPort(t *testing.T) {
616616
name: "with a control plane endpoint",
617617
openStackCluster: &infrav1.OpenStackCluster{
618618
Spec: infrav1.OpenStackClusterSpec{
619-
ControlPlaneEndpoint: &clusterv1b1.APIEndpoint{
619+
ControlPlaneEndpoint: &clusterv1beta1.APIEndpoint{
620620
Host: "192.168.0.1",
621621
Port: 6444,
622622
},

controllers/openstackfloatingippool_controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import (
2828
"k8s.io/apimachinery/pkg/util/wait"
2929
"k8s.io/client-go/tools/record"
3030
"k8s.io/utils/ptr"
31-
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
31+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3232
ipamv1 "sigs.k8s.io/cluster-api/api/ipam/v1beta2"
33-
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
33+
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
3434
"sigs.k8s.io/cluster-api/util/patch"
3535
ctrl "sigs.k8s.io/controller-runtime"
3636
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -196,7 +196,7 @@ func (r *OpenStackFloatingIPPoolReconciler) Reconcile(ctx context.Context, req c
196196
scope.Logger().Info("Claimed IP", "ip", ipAddress.Spec.Address)
197197
}
198198
}
199-
conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
199+
v1beta1conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
200200
return ctrl.Result{}, r.Client.Status().Update(ctx, pool)
201201
}
202202

@@ -354,14 +354,14 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope *sc
354354
// If we have reached the maximum number of IPs, we should not create more IPs
355355
if maxIPs != -1 && len(pool.Status.ClaimedIPs) >= maxIPs {
356356
scope.Logger().Info("MaxIPs reached", "pool", pool.Name)
357-
conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1alpha1.MaxIPsReachedReason, clusterv1b1.ConditionSeverityError, "Maximum number of IPs reached, we will not allocate more IPs for this pool")
357+
v1beta1conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1alpha1.MaxIPsReachedReason, clusterv1beta1.ConditionSeverityError, "Maximum number of IPs reached, we will not allocate more IPs for this pool")
358358
return "", errMaxIPsReached
359359
}
360360

361361
fp, err := networkingService.CreateFloatingIPForPool(pool)
362362
if err != nil {
363363
scope.Logger().Error(err, "Failed to create floating IP", "pool", pool.Name)
364-
conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1.OpenStackErrorReason, clusterv1b1.ConditionSeverityError, "Failed to create floating IP: %v", err)
364+
v1beta1conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1.OpenStackErrorReason, clusterv1beta1.ConditionSeverityError, "Failed to create floating IP: %v", err)
365365
return "", err
366366
}
367367
defer func() {
@@ -379,7 +379,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope *sc
379379
}
380380
}()
381381

382-
conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
382+
v1beta1conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
383383
ip = fp.FloatingIP
384384
pool.Status.ClaimedIPs = append(pool.Status.ClaimedIPs, ip)
385385
return ip, nil
@@ -408,7 +408,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc
408408

409409
network, err := networkingService.GetNetworkByParam(networkParam, networking.ExternalNetworksOnly)
410410
if err != nil {
411-
conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1alpha1.UnableToFindNetwork, clusterv1b1.ConditionSeverityError, "Failed to find network: %v", err)
411+
v1beta1conditions.MarkFalse(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition, infrav1alpha1.UnableToFindNetwork, clusterv1beta1.ConditionSeverityError, "Failed to find network: %v", err)
412412
return fmt.Errorf("failed to find network: %w", err)
413413
}
414414

0 commit comments

Comments
 (0)