@@ -20,12 +20,10 @@ import (
2020 apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2121 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222 "k8s.io/client-go/rest"
23- "k8s.io/utils/ptr"
2423)
2524
2625var (
27- typeTxtRecord = ptr .To (dnsclient .RecordType ("TXT" ))
28- emptyConfig = & apiextensionsv1.JSON {Raw : []byte ("{}" )}
26+ typeTxtRecord = toPTR (dnsclient .RecordType ("TXT" ))
2927 errK8Client = errors .New ("k8 client error" )
3028)
3129
@@ -111,11 +109,11 @@ func (s *ResolverTestSuite) TestPresent() {
111109 name : "zone already exists" ,
112110 givenZones : []dnsclient.ZoneRead {
113111 {
114- Id : ptr . To ("test-zone-id" ),
112+ Id : toPTR ("test-zone-id" ),
115113 Properties : & dnsclient.Zone {
116- ZoneName : ptr . To ("test.com" ),
114+ ZoneName : toPTR ("test.com" ),
117115 },
118- Type : ptr . To ("NATIVE" ),
116+ Type : toPTR ("NATIVE" ),
119117 },
120118 },
121119 givenRecords : []dnsclient.RecordRead {},
@@ -132,20 +130,20 @@ func (s *ResolverTestSuite) TestPresent() {
132130 name : "record with the same name and key already exists" ,
133131 givenZones : []dnsclient.ZoneRead {
134132 {
135- Id : ptr . To ("test-zone-id" ),
133+ Id : toPTR ("test-zone-id" ),
136134 Properties : & dnsclient.Zone {
137- ZoneName : ptr . To ("test.com" ),
135+ ZoneName : toPTR ("test.com" ),
138136 },
139- Type : ptr . To ("NATIVE" ),
137+ Type : toPTR ("NATIVE" ),
140138 },
141139 },
142140 givenRecords : []dnsclient.RecordRead {
143141 {
144- Id : ptr . To ("test-record-id" ),
142+ Id : toPTR ("test-record-id" ),
145143 Properties : & dnsclient.Record {
146- Name : ptr . To ("_acme-challenge" ),
144+ Name : toPTR ("_acme-challenge" ),
147145 Type : typeTxtRecord ,
148- Content : ptr . To ("test-key" ),
146+ Content : toPTR ("test-key" ),
149147 },
150148 },
151149 },
@@ -162,20 +160,20 @@ func (s *ResolverTestSuite) TestPresent() {
162160 name : "record with the same name but different key already exists" ,
163161 givenZones : []dnsclient.ZoneRead {
164162 {
165- Id : ptr . To ("test-zone-id" ),
163+ Id : toPTR ("test-zone-id" ),
166164 Properties : & dnsclient.Zone {
167- ZoneName : ptr . To ("test.com" ),
165+ ZoneName : toPTR ("test.com" ),
168166 },
169- Type : ptr . To ("NATIVE" ),
167+ Type : toPTR ("NATIVE" ),
170168 },
171169 },
172170 givenRecords : []dnsclient.RecordRead {
173171 {
174- Id : ptr . To ("test-record-id" ),
172+ Id : toPTR ("test-record-id" ),
175173 Properties : & dnsclient.Record {
176- Name : ptr . To ("_acme-challenge" ),
174+ Name : toPTR ("_acme-challenge" ),
177175 Type : typeTxtRecord ,
178- Content : ptr . To ("different-key" ),
176+ Content : toPTR ("different-key" ),
179177 },
180178 },
181179 },
@@ -205,11 +203,11 @@ func (s *ResolverTestSuite) TestPresent() {
205203 name : "error fetching records" ,
206204 givenZones : []dnsclient.ZoneRead {
207205 {
208- Id : ptr . To ("test-zone-id" ),
206+ Id : toPTR ("test-zone-id" ),
209207 Properties : & dnsclient.Zone {
210- ZoneName : ptr . To ("test.com" ),
208+ ZoneName : toPTR ("test.com" ),
211209 },
212- Type : ptr . To ("NATIVE" ),
210+ Type : toPTR ("NATIVE" ),
213211 },
214212 },
215213 givenRecords : []dnsclient.RecordRead {},
@@ -227,11 +225,11 @@ func (s *ResolverTestSuite) TestPresent() {
227225 name : "error creating record" ,
228226 givenZones : []dnsclient.ZoneRead {
229227 {
230- Id : ptr . To ("test-zone-id" ),
228+ Id : toPTR ("test-zone-id" ),
231229 Properties : & dnsclient.Zone {
232- ZoneName : ptr . To ("test.com" ),
230+ ZoneName : toPTR ("test.com" ),
233231 },
234- Type : ptr . To ("NATIVE" ),
232+ Type : toPTR ("NATIVE" ),
235233 },
236234 },
237235 givenRecords : []dnsclient.RecordRead {},
@@ -270,7 +268,7 @@ func (s *ResolverTestSuite) TestPresent() {
270268 if tc .thenRecordCreateKey != "" {
271269 s .dnsAPIMock .EXPECT ().CreateTXTRecord ("test-zone-id" , "_acme-challenge" , tc .thenRecordCreateKey ).
272270 Return (dnsclient.RecordRead {
273- Id : ptr . To ("test-record-id" ),
271+ Id : toPTR ("test-record-id" ),
274272 }, tc .whenRecordCreateError )
275273 }
276274 }
@@ -346,11 +344,11 @@ func (s *ResolverTestSuite) TestCleanUp() {
346344 name : "zone exists, but no record" ,
347345 givenZones : []dnsclient.ZoneRead {
348346 {
349- Id : ptr . To ("test-zone-id" ),
347+ Id : toPTR ("test-zone-id" ),
350348 Properties : & dnsclient.Zone {
351- ZoneName : ptr . To ("test.com" ),
349+ ZoneName : toPTR ("test.com" ),
352350 },
353- Type : ptr . To ("NATIVE" ),
351+ Type : toPTR ("NATIVE" ),
354352 },
355353 },
356354 givenRecords : []dnsclient.RecordRead {},
@@ -368,20 +366,20 @@ func (s *ResolverTestSuite) TestCleanUp() {
368366 name : "zone and record with same name exists, but has a different key" ,
369367 givenZones : []dnsclient.ZoneRead {
370368 {
371- Id : ptr . To ("test-zone-id" ),
369+ Id : toPTR ("test-zone-id" ),
372370 Properties : & dnsclient.Zone {
373- ZoneName : ptr . To ("test.com" ),
371+ ZoneName : toPTR ("test.com" ),
374372 },
375- Type : ptr . To ("NATIVE" ),
373+ Type : toPTR ("NATIVE" ),
376374 },
377375 },
378376 givenRecords : []dnsclient.RecordRead {
379377 {
380- Id : ptr . To ("test-record-id" ),
378+ Id : toPTR ("test-record-id" ),
381379 Properties : & dnsclient.Record {
382- Name : ptr . To ("_acme-challenge" ),
380+ Name : toPTR ("_acme-challenge" ),
383381 Type : typeTxtRecord ,
384- Content : ptr . To ("different-key" ),
382+ Content : toPTR ("different-key" ),
385383 },
386384 },
387385 },
@@ -412,11 +410,11 @@ func (s *ResolverTestSuite) TestCleanUp() {
412410 name : "record read error" ,
413411 givenZones : []dnsclient.ZoneRead {
414412 {
415- Id : ptr . To ("test-zone-id" ),
413+ Id : toPTR ("test-zone-id" ),
416414 Properties : & dnsclient.Zone {
417- ZoneName : ptr . To ("test.com" ),
415+ ZoneName : toPTR ("test.com" ),
418416 },
419- Type : ptr . To ("NATIVE" ),
417+ Type : toPTR ("NATIVE" ),
420418 },
421419 },
422420 givenRecords : []dnsclient.RecordRead {},
@@ -434,20 +432,20 @@ func (s *ResolverTestSuite) TestCleanUp() {
434432 name : "record delete error" ,
435433 givenZones : []dnsclient.ZoneRead {
436434 {
437- Id : ptr . To ("test-zone-id" ),
435+ Id : toPTR ("test-zone-id" ),
438436 Properties : & dnsclient.Zone {
439- ZoneName : ptr . To ("test.com" ),
437+ ZoneName : toPTR ("test.com" ),
440438 },
441- Type : ptr . To ("NATIVE" ),
439+ Type : toPTR ("NATIVE" ),
442440 },
443441 },
444442 givenRecords : []dnsclient.RecordRead {
445443 {
446- Id : ptr . To ("test-record-id" ),
444+ Id : toPTR ("test-record-id" ),
447445 Properties : & dnsclient.Record {
448- Name : ptr . To ("_acme-challenge" ),
446+ Name : toPTR ("_acme-challenge" ),
449447 Type : typeTxtRecord ,
450- Content : ptr . To ("test-key" ),
448+ Content : toPTR ("test-key" ),
451449 },
452450 },
453451 },
@@ -466,20 +464,20 @@ func (s *ResolverTestSuite) TestCleanUp() {
466464 name : "record with key exists" ,
467465 givenZones : []dnsclient.ZoneRead {
468466 {
469- Id : ptr . To ("test-zone-id" ),
467+ Id : toPTR ("test-zone-id" ),
470468 Properties : & dnsclient.Zone {
471- ZoneName : ptr . To ("test.com" ),
469+ ZoneName : toPTR ("test.com" ),
472470 },
473- Type : ptr . To ("NATIVE" ),
471+ Type : toPTR ("NATIVE" ),
474472 },
475473 },
476474 givenRecords : []dnsclient.RecordRead {
477475 {
478- Id : ptr . To ("test-record-id" ),
476+ Id : toPTR ("test-record-id" ),
479477 Properties : & dnsclient.Record {
480- Name : ptr . To ("_acme-challenge" ),
478+ Name : toPTR ("_acme-challenge" ),
481479 Type : typeTxtRecord ,
482- Content : ptr . To ("test-key" ),
480+ Content : toPTR ("test-key" ),
483481 },
484482 },
485483 },
@@ -555,3 +553,7 @@ func setUpK8ClientExpectations(k8Client *mocks.K8Client, err error, t *testing.T
555553
556554 k8Client .EXPECT ().CoreV1 ().Return (coreV1Interface )
557555}
556+
557+ func toPTR [C any ](c C ) * C {
558+ return & c
559+ }
0 commit comments