@@ -49,59 +49,60 @@ type managedZonesListCallInterface interface {
49
49
}
50
50
51
51
type managedZonesServiceInterface interface {
52
- Create (project string , managedzone * dns.ManagedZone ) managedZonesCreateCallInterface
53
- List (project string ) managedZonesListCallInterface
52
+ Create (managedZone * dns.ManagedZone ) managedZonesCreateCallInterface
53
+ List () managedZonesListCallInterface
54
54
}
55
55
56
56
type resourceRecordSetsListCallInterface interface {
57
57
Pages (ctx context.Context , f func (* dns.ResourceRecordSetsListResponse ) error ) error
58
58
}
59
59
60
60
type resourceRecordSetsClientInterface interface {
61
- List (project string , managedZone string ) resourceRecordSetsListCallInterface
61
+ List (managedZone string ) resourceRecordSetsListCallInterface
62
62
}
63
63
64
64
type changesCreateCallInterface interface {
65
65
Do (opts ... googleapi.CallOption ) (* dns.Change , error )
66
66
}
67
67
68
68
type changesServiceInterface interface {
69
- Create (project string , managedZone string , change * dns.Change ) changesCreateCallInterface
69
+ Create (managedZone string , change * dns.Change ) changesCreateCallInterface
70
70
}
71
71
72
72
type resourceRecordSetsService struct {
73
+ project string
73
74
service * dns.ResourceRecordSetsService
74
75
}
75
76
76
- func (r resourceRecordSetsService ) List (project string , managedZone string ) resourceRecordSetsListCallInterface {
77
- return r .service .List (project , managedZone )
77
+ func (r resourceRecordSetsService ) List (managedZone string ) resourceRecordSetsListCallInterface {
78
+ return r .service .List (r . project , managedZone )
78
79
}
79
80
80
81
type managedZonesService struct {
82
+ project string
81
83
service * dns.ManagedZonesService
82
84
}
83
85
84
- func (m managedZonesService ) Create (project string , managedzone * dns.ManagedZone ) managedZonesCreateCallInterface {
85
- return m .service .Create (project , managedzone )
86
+ func (m managedZonesService ) Create (managedZone * dns.ManagedZone ) managedZonesCreateCallInterface {
87
+ return m .service .Create (m . project , managedZone )
86
88
}
87
89
88
- func (m managedZonesService ) List (project string ) managedZonesListCallInterface {
89
- return m .service .List (project )
90
+ func (m managedZonesService ) List () managedZonesListCallInterface {
91
+ return m .service .List (m . project )
90
92
}
91
93
92
94
type changesService struct {
95
+ project string
93
96
service * dns.ChangesService
94
97
}
95
98
96
- func (c changesService ) Create (project string , managedZone string , change * dns.Change ) changesCreateCallInterface {
97
- return c .service .Create (project , managedZone , change )
99
+ func (c changesService ) Create (managedZone string , change * dns.Change ) changesCreateCallInterface {
100
+ return c .service .Create (c . project , managedZone , change )
98
101
}
99
102
100
103
// GoogleProvider is an implementation of Provider for Google CloudDNS.
101
104
type GoogleProvider struct {
102
105
provider.BaseProvider
103
- // The Google project to work in
104
- project string
105
106
// Enabled dry-run will print any modifying actions rather than execute them.
106
107
dryRun bool
107
108
// Max batch size to submit to Google Cloud DNS per transaction.
@@ -155,17 +156,25 @@ func NewGoogleProvider(ctx context.Context, project string, domainFilter endpoin
155
156
zoneTypeFilter := provider .NewZoneTypeFilter (zoneVisibility )
156
157
157
158
provider := & GoogleProvider {
158
- project : project ,
159
- dryRun : dryRun ,
160
- batchChangeSize : batchChangeSize ,
161
- batchChangeInterval : batchChangeInterval ,
162
- domainFilter : domainFilter ,
163
- zoneTypeFilter : zoneTypeFilter ,
164
- zoneIDFilter : zoneIDFilter ,
165
- resourceRecordSetsClient : resourceRecordSetsService {dnsClient .ResourceRecordSets },
166
- managedZonesClient : managedZonesService {dnsClient .ManagedZones },
167
- changesClient : changesService {dnsClient .Changes },
168
- ctx : ctx ,
159
+ dryRun : dryRun ,
160
+ batchChangeSize : batchChangeSize ,
161
+ batchChangeInterval : batchChangeInterval ,
162
+ domainFilter : domainFilter ,
163
+ zoneTypeFilter : zoneTypeFilter ,
164
+ zoneIDFilter : zoneIDFilter ,
165
+ managedZonesClient : managedZonesService {
166
+ project : project ,
167
+ service : dnsClient .ManagedZones ,
168
+ },
169
+ resourceRecordSetsClient : resourceRecordSetsService {
170
+ project : project ,
171
+ service : dnsClient .ResourceRecordSets ,
172
+ },
173
+ changesClient : changesService {
174
+ project : project ,
175
+ service : dnsClient .Changes ,
176
+ },
177
+ ctx : ctx ,
169
178
}
170
179
171
180
return provider , nil
@@ -193,12 +202,12 @@ func (p *GoogleProvider) Zones(ctx context.Context) (map[string]*dns.ManagedZone
193
202
}
194
203
195
204
log .Debugf ("Matching zones against domain filters: %v" , p .domainFilter )
196
- if err := p .managedZonesClient .List (p . project ).Pages (ctx , f ); err != nil {
205
+ if err := p .managedZonesClient .List ().Pages (ctx , f ); err != nil {
197
206
return nil , provider .NewSoftError (fmt .Errorf ("failed to list zones: %w" , err ))
198
207
}
199
208
200
209
if len (zones ) == 0 {
201
- log .Warnf ("No zones in the project, %s, match domain filters: %v" , p . project , p .domainFilter )
210
+ log .Warnf ("No zones match domain filters: %v" , p .domainFilter )
202
211
}
203
212
204
213
for _ , zone := range zones {
@@ -227,7 +236,7 @@ func (p *GoogleProvider) Records(ctx context.Context) (endpoints []*endpoint.End
227
236
}
228
237
229
238
for _ , z := range zones {
230
- if err := p .resourceRecordSetsClient .List (p . project , z .Name ).Pages (ctx , f ); err != nil {
239
+ if err := p .resourceRecordSetsClient .List (z .Name ).Pages (ctx , f ); err != nil {
231
240
return nil , provider .NewSoftError (fmt .Errorf ("failed to list records in zone %s: %w" , z .Name , err ))
232
241
}
233
242
}
@@ -301,7 +310,7 @@ func (p *GoogleProvider) submitChange(ctx context.Context, change *dns.Change) e
301
310
continue
302
311
}
303
312
304
- if _ , err := p .changesClient .Create (p . project , zone , c ).Do (); err != nil {
313
+ if _ , err := p .changesClient .Create (zone , c ).Do (); err != nil {
305
314
return provider .NewSoftError (fmt .Errorf ("failed to create changes: %w" , err ))
306
315
}
307
316
0 commit comments