@@ -23,9 +23,7 @@ import (
23
23
24
24
. "github.com/onsi/ginkgo/v2"
25
25
. "github.com/onsi/gomega"
26
- corev1 "k8s.io/api/core/v1"
27
26
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
- "k8s.io/utils/pointer"
29
27
ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1alpha1"
30
28
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
31
29
@@ -68,19 +66,7 @@ var _ = Describe("IP Pool Reconciler", func() {
68
66
Expect (genericPool .PoolStatus ().Addresses .Free ).To (Equal (expectedTotal ))
69
67
70
68
for i := 0 ; i < expectedUsed ; i ++ {
71
- claim := ipamv1.IPAddressClaim {
72
- ObjectMeta : metav1.ObjectMeta {
73
- Name : fmt .Sprintf ("test%d" , i ),
74
- Namespace : namespace ,
75
- },
76
- Spec : ipamv1.IPAddressClaimSpec {
77
- PoolRef : corev1.TypedLocalObjectReference {
78
- APIGroup : pointer .String ("ipam.cluster.x-k8s.io" ),
79
- Kind : poolType ,
80
- Name : genericPool .GetName (),
81
- },
82
- },
83
- }
69
+ claim := newClaim (fmt .Sprintf ("test%d" , i ), namespace , poolType , genericPool .GetName ())
84
70
Expect (k8sClient .Create (context .Background (), & claim )).To (Succeed ())
85
71
createdClaimNames = append (createdClaimNames , claim .Name )
86
72
}
@@ -155,19 +141,7 @@ var _ = Describe("IP Pool Reconciler", func() {
155
141
Expect (k8sClient .Create (context .Background (), genericPool )).To (Succeed ())
156
142
157
143
for i := 0 ; i < numClaims ; i ++ {
158
- claim := ipamv1.IPAddressClaim {
159
- ObjectMeta : metav1.ObjectMeta {
160
- Name : fmt .Sprintf ("test%d" , i ),
161
- Namespace : namespace ,
162
- },
163
- Spec : ipamv1.IPAddressClaimSpec {
164
- PoolRef : corev1.TypedLocalObjectReference {
165
- APIGroup : pointer .String ("ipam.cluster.x-k8s.io" ),
166
- Kind : poolType ,
167
- Name : genericPool .GetName (),
168
- },
169
- },
170
- }
144
+ claim := newClaim (fmt .Sprintf ("test%d" , i ), namespace , poolType , genericPool .GetName ())
171
145
Expect (k8sClient .Create (context .Background (), & claim )).To (Succeed ())
172
146
createdClaimNames = append (createdClaimNames , claim .Name )
173
147
}
@@ -212,19 +186,7 @@ var _ = Describe("IP Pool Reconciler", func() {
212
186
Expect (k8sClient .Create (context .Background (), pool )).To (Succeed ())
213
187
Eventually (Get (pool )).Should (Succeed ())
214
188
215
- claim := ipamv1.IPAddressClaim {
216
- ObjectMeta : metav1.ObjectMeta {
217
- Name : "finalizer-pool-test" ,
218
- Namespace : namespace ,
219
- },
220
- Spec : ipamv1.IPAddressClaimSpec {
221
- PoolRef : corev1.TypedLocalObjectReference {
222
- APIGroup : pointer .String ("ipam.cluster.x-k8s.io" ),
223
- Kind : poolType ,
224
- Name : pool .GetName (),
225
- },
226
- },
227
- }
189
+ claim := newClaim ("finalizer-pool-test" , namespace , poolType , pool .GetName ())
228
190
229
191
Expect (k8sClient .Create (context .Background (), & claim )).To (Succeed ())
230
192
0 commit comments