Skip to content

Commit 99f3a60

Browse files
authored
Merge pull request #1962 from shiftstack/floatingipv1beta1
🌱 Update FloatingIPPool to use v1beta1
2 parents 66d93db + 24b7961 commit 99f3a60

File tree

5 files changed

+76
-53
lines changed

5 files changed

+76
-53
lines changed

api/v1alpha1/openstackfloatingippool_types.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2424

25-
// We use v1alpha7 here rather than anything newer because as of writing
26-
// it is the newest API version we should no longer be making breaking
27-
// changes to. If we bump this we need to look carefully for resulting
28-
// CRD changes in v1alpha1 to ensure they are compatible.
29-
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
25+
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
3026
)
3127

3228
const (
@@ -62,16 +58,12 @@ type OpenStackFloatingIPPoolSpec struct {
6258
MaxIPs *int `json:"maxIPs,omitempty"`
6359

6460
// IdentityRef is a reference to a identity to be used when reconciling this pool.
65-
// +optional
66-
IdentityRef *infrav1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"`
61+
// +kubebuilder:validation:Required
62+
IdentityRef infrav1.OpenStackIdentityReference `json:"identityRef"`
6763

6864
// FloatingIPNetwork is the external network to use for floating ips, if there's only one external network it will be used by default
6965
// +optional
70-
FloatingIPNetwork infrav1alpha7.NetworkFilter `json:"floatingIPNetwork"`
71-
72-
// The name of the cloud to use from the clouds secret
73-
// +optional
74-
CloudName string `json:"cloudName"`
66+
FloatingIPNetwork infrav1.NetworkFilter `json:"floatingIPNetwork"`
7567

7668
// The stratergy to use for reclaiming floating ips when they are released from a machine
7769
// +kubebuilder:validation:Optional
@@ -95,7 +87,7 @@ type OpenStackFloatingIPPoolStatus struct {
9587

9688
// floatingIPNetwork contains information about the network used for floating ips
9789
// +optional
98-
FloatingIPNetwork *infrav1alpha7.NetworkStatus `json:"floatingIPNetwork,omitempty"`
90+
FloatingIPNetwork *infrav1.NetworkStatus `json:"floatingIPNetwork,omitempty"`
9991

10092
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
10193
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackfloatingippools.yaml

Lines changed: 59 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/openstackfloatingippool_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ import (
4141
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4242

4343
infrav1alpha1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha1"
44-
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
4544
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
4645
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/networking"
4746
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
48-
filterconvert "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/filterconvert/v1alpha7"
47+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/filterconvert"
4948
)
5049

5150
const (
@@ -402,7 +401,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc
402401
}
403402

404403
netListOpts := external.ListOptsExt{
405-
ListOptsBuilder: filterconvert.NetworkFilterToListOpt(&pool.Spec.FloatingIPNetwork),
404+
ListOptsBuilder: filterconvert.NetworkFilterToListOpts(&pool.Spec.FloatingIPNetwork),
406405
External: pointer.Bool(true),
407406
}
408407

@@ -414,7 +413,7 @@ func (r *OpenStackFloatingIPPoolReconciler) reconcileFloatingIPNetwork(scope *sc
414413
return fmt.Errorf("found multiple networks, expects filter to match one (result: %v)", networkList)
415414
}
416415

417-
pool.Status.FloatingIPNetwork = &infrav1alpha7.NetworkStatus{
416+
pool.Status.FloatingIPNetwork = &infrav1.NetworkStatus{
418417
ID: networkList[0].ID,
419418
Name: networkList[0].Name,
420419
Tags: networkList[0].Tags,

pkg/scope/provider.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,9 @@ func (f *providerScopeFactory) NewClientScopeFromCluster(ctx context.Context, ct
106106
}
107107

108108
func (f *providerScopeFactory) NewClientScopeFromFloatingIPPool(ctx context.Context, ctrlClient client.Client, openstackFloatingIPPool *v1alpha1.OpenStackFloatingIPPool, defaultCACert []byte, logger logr.Logger) (Scope, error) {
109-
var cloud clientconfig.Cloud
110-
var caCert []byte
111-
112-
if openstackFloatingIPPool.Spec.IdentityRef != nil {
113-
var err error
114-
cloud, caCert, err = getCloudFromSecret(ctx, ctrlClient, openstackFloatingIPPool.Namespace, openstackFloatingIPPool.Spec.IdentityRef.Name, openstackFloatingIPPool.Spec.CloudName)
115-
if err != nil {
116-
return nil, err
117-
}
109+
cloud, caCert, err := getCloudFromSecret(ctx, ctrlClient, openstackFloatingIPPool.Namespace, openstackFloatingIPPool.Spec.IdentityRef.Name, openstackFloatingIPPool.Spec.IdentityRef.CloudName)
110+
if err != nil {
111+
return nil, err
118112
}
119113

120114
if caCert == nil {

0 commit comments

Comments
 (0)