@@ -18,16 +18,17 @@ limitations under the License.
18
18
package client
19
19
20
20
import (
21
+ "context"
21
22
"net"
22
23
"net/http"
23
24
"os"
24
25
"time"
25
26
26
- "github.com/gophercloud/gophercloud"
27
- "github.com/gophercloud/gophercloud/openstack"
28
- "github.com/gophercloud/gophercloud/openstack/dns/v2/recordsets"
29
- "github.com/gophercloud/gophercloud/openstack/dns/v2/zones"
30
- "github.com/gophercloud/gophercloud/pagination"
27
+ "github.com/gophercloud/gophercloud/v2 "
28
+ "github.com/gophercloud/gophercloud/v2/ openstack"
29
+ "github.com/gophercloud/gophercloud/v2/ openstack/dns/v2/recordsets"
30
+ "github.com/gophercloud/gophercloud/v2/ openstack/dns/v2/zones"
31
+ "github.com/gophercloud/gophercloud/v2/ pagination"
31
32
log "github.com/sirupsen/logrus"
32
33
33
34
"sigs.k8s.io/external-dns/pkg/tlsutils"
@@ -36,19 +37,19 @@ import (
36
37
// interface between provider and OpenStack DNS API
37
38
type DesignateClientInterface interface {
38
39
// ForEachZone calls handler for each zone managed by the Designate
39
- ForEachZone (handler func (zone * zones.Zone ) error ) error
40
+ ForEachZone (ctx context. Context , handler func (zone * zones.Zone ) error ) error
40
41
41
42
// ForEachRecordSet calls handler for each recordset in the given DNS zone
42
- ForEachRecordSet (zoneID string , handler func (recordSet * recordsets.RecordSet ) error ) error
43
+ ForEachRecordSet (ctx context. Context , zoneID string , handler func (recordSet * recordsets.RecordSet ) error ) error
43
44
44
45
// CreateRecordSet creates recordset in the given DNS zone
45
- CreateRecordSet (zoneID string , opts recordsets.CreateOpts ) (string , error )
46
+ CreateRecordSet (ctx context. Context , zoneID string , opts recordsets.CreateOpts ) (string , error )
46
47
47
48
// UpdateRecordSet updates recordset in the given DNS zone
48
- UpdateRecordSet (zoneID , recordSetID string , opts recordsets.UpdateOpts ) error
49
+ UpdateRecordSet (ctx context. Context , zoneID , recordSetID string , opts recordsets.UpdateOpts ) error
49
50
50
51
// DeleteRecordSet deletes recordset in the given DNS zone
51
- DeleteRecordSet (zoneID , recordSetID string ) error
52
+ DeleteRecordSet (ctx context. Context , zoneID , recordSetID string ) error
52
53
}
53
54
54
55
// implementation of the DesignateClientInterface
@@ -126,7 +127,8 @@ func createDesignateServiceClient() (*gophercloud.ServiceClient, error) {
126
127
}
127
128
authProvider .HTTPClient .Transport = transport
128
129
129
- if err = openstack .Authenticate (authProvider , opts ); err != nil {
130
+ ctx := context .Background ()
131
+ if err = openstack .Authenticate (ctx , authProvider , opts ); err != nil {
130
132
return nil , err
131
133
}
132
134
@@ -143,10 +145,10 @@ func createDesignateServiceClient() (*gophercloud.ServiceClient, error) {
143
145
}
144
146
145
147
// ForEachZone calls handler for each zone managed by the Designate
146
- func (c designateClient ) ForEachZone (handler func (zone * zones.Zone ) error ) error {
148
+ func (c designateClient ) ForEachZone (ctx context. Context , handler func (zone * zones.Zone ) error ) error {
147
149
pager := zones .List (c .serviceClient , zones.ListOpts {})
148
- return pager .EachPage (
149
- func (page pagination.Page ) (bool , error ) {
150
+ return pager .EachPage (ctx ,
151
+ func (ctx context. Context , page pagination.Page ) (bool , error ) {
150
152
list , err := zones .ExtractZones (page )
151
153
if err != nil {
152
154
return false , err
@@ -163,10 +165,10 @@ func (c designateClient) ForEachZone(handler func(zone *zones.Zone) error) error
163
165
}
164
166
165
167
// ForEachRecordSet calls handler for each recordset in the given DNS zone
166
- func (c designateClient ) ForEachRecordSet (zoneID string , handler func (recordSet * recordsets.RecordSet ) error ) error {
168
+ func (c designateClient ) ForEachRecordSet (ctx context. Context , zoneID string , handler func (recordSet * recordsets.RecordSet ) error ) error {
167
169
pager := recordsets .ListByZone (c .serviceClient , zoneID , recordsets.ListOpts {})
168
- return pager .EachPage (
169
- func (page pagination.Page ) (bool , error ) {
170
+ return pager .EachPage (ctx ,
171
+ func (ctx context. Context , page pagination.Page ) (bool , error ) {
170
172
list , err := recordsets .ExtractRecordSets (page )
171
173
if err != nil {
172
174
return false , err
@@ -183,21 +185,21 @@ func (c designateClient) ForEachRecordSet(zoneID string, handler func(recordSet
183
185
}
184
186
185
187
// CreateRecordSet creates recordset in the given DNS zone
186
- func (c designateClient ) CreateRecordSet (zoneID string , opts recordsets.CreateOpts ) (string , error ) {
187
- r , err := recordsets .Create (c .serviceClient , zoneID , opts ).Extract ()
188
+ func (c designateClient ) CreateRecordSet (ctx context. Context , zoneID string , opts recordsets.CreateOpts ) (string , error ) {
189
+ r , err := recordsets .Create (ctx , c .serviceClient , zoneID , opts ).Extract ()
188
190
if err != nil {
189
191
return "" , err
190
192
}
191
193
return r .ID , nil
192
194
}
193
195
194
196
// UpdateRecordSet updates recordset in the given DNS zone
195
- func (c designateClient ) UpdateRecordSet (zoneID , recordSetID string , opts recordsets.UpdateOpts ) error {
196
- _ , err := recordsets .Update (c .serviceClient , zoneID , recordSetID , opts ).Extract ()
197
+ func (c designateClient ) UpdateRecordSet (ctx context. Context , zoneID , recordSetID string , opts recordsets.UpdateOpts ) error {
198
+ _ , err := recordsets .Update (ctx , c .serviceClient , zoneID , recordSetID , opts ).Extract ()
197
199
return err
198
200
}
199
201
200
202
// DeleteRecordSet deletes recordset in the given DNS zone
201
- func (c designateClient ) DeleteRecordSet (zoneID , recordSetID string ) error {
202
- return recordsets .Delete (c .serviceClient , zoneID , recordSetID ).ExtractErr ()
203
+ func (c designateClient ) DeleteRecordSet (ctx context. Context , zoneID , recordSetID string ) error {
204
+ return recordsets .Delete (ctx , c .serviceClient , zoneID , recordSetID ).ExtractErr ()
203
205
}
0 commit comments