55 "fmt"
66
77 machinev1 "github.com/openshift/api/machine/v1beta1"
8- ipamv1beta1 "sigs.k8s.io/cluster-api/api/ipam/v1beta1" //nolint:staticcheck
8+ ipamv1 "sigs.k8s.io/cluster-api/api/ipam/v1beta2"
99
10- corev1 "k8s.io/api/core/v1"
1110 apierrors "k8s.io/apimachinery/pkg/api/errors"
1211 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1312 "k8s.io/apimachinery/pkg/util/sets"
@@ -21,12 +20,12 @@ func EnsureIPAddressClaim(
2120 runtimeClient client.Client ,
2221 claimName string ,
2322 machine * machinev1.Machine ,
24- pool machinev1.AddressesFromPool ) (* ipamv1beta1 .IPAddressClaim , error ) {
23+ pool machinev1.AddressesFromPool ) (* ipamv1 .IPAddressClaim , error ) {
2524 claimKey := client.ObjectKey {
2625 Namespace : machine .Namespace ,
2726 Name : claimName ,
2827 }
29- ipAddressClaim := & ipamv1beta1 .IPAddressClaim {}
28+ ipAddressClaim := & ipamv1 .IPAddressClaim {}
3029 if err := runtimeClient .Get (ctx , claimKey , ipAddressClaim ); err == nil {
3130 // If we found a claim, make sure it has owner field set.
3231 if len (ipAddressClaim .OwnerReferences ) == 0 {
@@ -41,7 +40,7 @@ func EnsureIPAddressClaim(
4140 klog .Infof ("creating IPAddressClaim %s" , claimName )
4241 gv := machinev1 .SchemeGroupVersion
4342 machineRef := metav1 .NewControllerRef (machine , gv .WithKind ("Machine" ))
44- ipAddressClaim = & ipamv1beta1 .IPAddressClaim {
43+ ipAddressClaim = & ipamv1 .IPAddressClaim {
4544 ObjectMeta : metav1.ObjectMeta {
4645 OwnerReferences : []metav1.OwnerReference {
4746 * machineRef ,
@@ -52,9 +51,9 @@ func EnsureIPAddressClaim(
5251 Name : claimName ,
5352 Namespace : machine .Namespace ,
5453 },
55- Spec : ipamv1beta1 .IPAddressClaimSpec {
56- PoolRef : corev1. TypedLocalObjectReference {
57- APIGroup : & pool .Group ,
54+ Spec : ipamv1 .IPAddressClaimSpec {
55+ PoolRef : ipamv1. IPPoolReference {
56+ APIGroup : pool .Group ,
5857 Kind : pool .Resource ,
5958 Name : pool .Name ,
6059 },
@@ -72,7 +71,7 @@ func AdoptOrphanClaim(
7271 runtimeClient client.Client ,
7372 claimName string ,
7473 machine * machinev1.Machine ,
75- ipAddressClaim * ipamv1beta1 .IPAddressClaim ) error {
74+ ipAddressClaim * ipamv1 .IPAddressClaim ) error {
7675 gv := machinev1 .SchemeGroupVersion
7776 machineRef := metav1 .NewControllerRef (machine , gv .WithKind ("Machine" ))
7877 ipAddressClaim .OwnerReferences = []metav1.OwnerReference {
@@ -90,7 +89,7 @@ func AdoptOrphanClaim(
9089func CountOutstandingIPAddressClaimsForMachine (
9190 ctx context.Context ,
9291 runtimeClient client.Client ,
93- ipAddressClaims []ipamv1beta1 .IPAddressClaim ) int {
92+ ipAddressClaims []ipamv1 .IPAddressClaim ) int {
9493 fulfilledClaimCount := 0
9594
9695 for _ , claim := range ipAddressClaims {
@@ -107,13 +106,13 @@ func RetrieveBoundIPAddress(
107106 ctx context.Context ,
108107 runtimeClient client.Client ,
109108 machine * machinev1.Machine ,
110- claimName string ) (* ipamv1beta1 .IPAddress , error ) {
109+ claimName string ) (* ipamv1 .IPAddress , error ) {
111110
112111 claimKey := client.ObjectKey {
113112 Namespace : machine .Namespace ,
114113 Name : claimName ,
115114 }
116- ipAddressClaim := & ipamv1beta1 .IPAddressClaim {}
115+ ipAddressClaim := & ipamv1 .IPAddressClaim {}
117116 if err := runtimeClient .Get (ctx , claimKey , ipAddressClaim ); err != nil {
118117 return nil , fmt .Errorf ("unable to get IPAddressClaim: %w" , err )
119118 }
@@ -122,7 +121,7 @@ func RetrieveBoundIPAddress(
122121 return nil , fmt .Errorf ("no IPAddress is bound to claim %s" , claimName )
123122 }
124123
125- ipAddress := & ipamv1beta1 .IPAddress {}
124+ ipAddress := & ipamv1 .IPAddress {}
126125 addressKey := client.ObjectKey {
127126 Namespace : machine .Namespace ,
128127 Name : ipAddressClaim .Status .AddressRef .Name ,
@@ -137,7 +136,7 @@ func RemoveFinalizersForIPAddressClaims(
137136 ctx context.Context ,
138137 runtimeClient client.Client ,
139138 machine machinev1.Machine ) error {
140- ipAddressClaimList := & ipamv1beta1 .IPAddressClaimList {}
139+ ipAddressClaimList := & ipamv1 .IPAddressClaimList {}
141140 if err := runtimeClient .List (ctx , ipAddressClaimList , client .InNamespace (machine .Namespace )); err != nil {
142141 return fmt .Errorf ("unable to list IPAddressClaims: %w" , err )
143142 }
@@ -183,7 +182,7 @@ func HasOutstandingIPAddressClaims(
183182 machine * machinev1.Machine ,
184183 networkDevices []machinev1.NetworkDeviceSpec ,
185184) (int , error ) {
186- var associatedClaims []ipamv1beta1 .IPAddressClaim
185+ var associatedClaims []ipamv1 .IPAddressClaim
187186 for deviceIdx , networkDevice := range networkDevices {
188187 for poolIdx , addressPool := range networkDevice .AddressesFromPools {
189188 claimName := GetIPAddressClaimName (machine , deviceIdx , poolIdx )
0 commit comments