Skip to content

🌱 Unify and enforce CAPI import aliases #2645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,18 @@ linters-settings:
alias: clusterv1alpha3
- pkg: sigs.k8s.io/cluster-api/api/v1alpha4
alias: clusterv1alpha4
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
alias: clusterv1b1
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta2
alias: clusterv1
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta1
alias: clusterv1beta1
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions
alias: v1beta1conditions
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions/v1beta2
alias: deprecatedv1beta2conditions
- pkg: sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1
alias: deprecatedv1beta1conditions
- pkg: sigs.k8s.io/cluster-api/util/deprecated/v1beta1/patch
alias: v1beta1patch
- pkg: sigs.k8s.io/cluster-api/api/ipam/v1beta2
alias: ipamv1
# CABPK
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/openstackfloatingippool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"

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

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

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand All @@ -114,12 +114,12 @@ type OpenStackFloatingIPPoolList struct {
}

// GetConditions returns the observations of the operational state of the OpenStackFloatingIPPool resource.
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1.Conditions {
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1beta1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the OpenStackFloatingIPPool to the predescribed clusterv1.Conditions.
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1.Conditions) {
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1beta1.Conditions) {
r.Status.Conditions = conditions
}

Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/openstackserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"

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

// Conditions defines current service state of the OpenStackServer.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
}

// +genclient
Expand Down Expand Up @@ -185,12 +185,12 @@ type OpenStackServerList struct {
}

// GetConditions returns the observations of the operational state of the OpenStackServer resource.
func (r *OpenStackServer) GetConditions() clusterv1.Conditions {
func (r *OpenStackServer) GetConditions() clusterv1beta1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the OpenStackServer to the predescribed clusterv1.Conditions.
func (r *OpenStackServer) SetConditions(conditions clusterv1.Conditions) {
func (r *OpenStackServer) SetConditions(conditions clusterv1beta1.Conditions) {
r.Status.Conditions = conditions
}

Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ limitations under the License.

package v1beta1

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

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

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

const (
// 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.
APIServerIngressReadyCondition clusterv1.ConditionType = "APIServerIngressReadyCondition"
APIServerIngressReadyCondition clusterv1beta1.ConditionType = "APIServerIngressReadyCondition"

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

const (
// FloatingAddressFromPoolReadyCondition reports on the current status of the Floating IPs from ipam pool.
FloatingAddressFromPoolReadyCondition clusterv1.ConditionType = "FloatingAddressFromPoolReady"
FloatingAddressFromPoolReadyCondition clusterv1beta1.ConditionType = "FloatingAddressFromPoolReady"
// WaitingForIpamProviderReason used when machine is waiting for ipam provider to be ready before proceeding.
FloatingAddressFromPoolWaitingForIpamProviderReason = "WaitingForIPAMProvider"
// FloatingAddressFromPoolErrorReason is used when there is an error attaching an IP from the pool to an machine.
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/openstackcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package v1beta1

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

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

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

// FailureDomains represent OpenStack availability zones
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
FailureDomains clusterv1beta1.FailureDomains `json:"failureDomains,omitempty"`

// ControlPlaneSecurityGroup contains the information about the
// OpenStack Security Group that needs to be applied to control plane
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"

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

Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
}

// +genclient
Expand Down Expand Up @@ -267,12 +267,12 @@ type OpenStackMachineList struct {
}

// GetConditions returns the observations of the operational state of the OpenStackMachine resource.
func (r *OpenStackMachine) GetConditions() clusterv1.Conditions {
func (r *OpenStackMachine) GetConditions() clusterv1beta1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the OpenStackMachine to the predescribed clusterv1.Conditions.
func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) {
func (r *OpenStackMachine) SetConditions(conditions clusterv1beta1.Conditions) {
r.Status.Conditions = conditions
}

Expand Down
8 changes: 4 additions & 4 deletions controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
Expand Down Expand Up @@ -336,7 +336,7 @@ func (r *OpenStackClusterReconciler) reconcileNormal(ctx context.Context, scope
}

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

openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1b1.FailureDomainSpec{
openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1beta1.FailureDomainSpec{
ControlPlane: found,
}
}
Expand Down Expand Up @@ -873,7 +873,7 @@ func reconcileControlPlaneEndpoint(scope *scope.WithLogger, networkingService *n
return err
}

openStackCluster.Spec.ControlPlaneEndpoint = &clusterv1b1.APIEndpoint{
openStackCluster.Spec.ControlPlaneEndpoint = &clusterv1beta1.APIEndpoint{
Host: host,
Port: apiServerPort,
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/openstackcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/util/annotations"
Expand Down Expand Up @@ -616,7 +616,7 @@ func Test_getAPIServerPort(t *testing.T) {
name: "with a control plane endpoint",
openStackCluster: &infrav1.OpenStackCluster{
Spec: infrav1.OpenStackClusterSpec{
ControlPlaneEndpoint: &clusterv1b1.APIEndpoint{
ControlPlaneEndpoint: &clusterv1beta1.APIEndpoint{
Host: "192.168.0.1",
Port: 6444,
},
Expand Down
14 changes: 7 additions & 7 deletions controllers/openstackfloatingippool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"
clusterv1b1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
ipamv1 "sigs.k8s.io/cluster-api/api/ipam/v1beta2"
"sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
"sigs.k8s.io/cluster-api/util/patch"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -196,7 +196,7 @@ func (r *OpenStackFloatingIPPoolReconciler) Reconcile(ctx context.Context, req c
scope.Logger().Info("Claimed IP", "ip", ipAddress.Spec.Address)
}
}
conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
v1beta1conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
return ctrl.Result{}, r.Client.Status().Update(ctx, pool)
}

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

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

conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
v1beta1conditions.MarkTrue(pool, infrav1alpha1.OpenstackFloatingIPPoolReadyCondition)
ip = fp.FloatingIP
pool.Status.ClaimedIPs = append(pool.Status.ClaimedIPs, ip)
return ip, nil
Expand Down Expand Up @@ -408,7 +408,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc

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

Expand Down
Loading