1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

OVH: Allow ovh provider to connect to other endpoints than EU (#2625) (#2651)

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Brice Figureau
2023-11-28 00:18:24 +01:00
committed by GitHub
parent b5010e7d9c
commit 69fb3b26d3
4 changed files with 98 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ var features = providers.DocumentationNotes{
func newOVH(m map[string]string, metadata json.RawMessage) (*ovhProvider, error) {
appKey, appSecretKey, consumerKey := m["app-key"], m["app-secret-key"], m["consumer-key"]
c, err := ovh.NewClient(ovh.OvhEU, appKey, appSecretKey, consumerKey)
c, err := ovh.NewClient(getOVHEndpoint(m), appKey, appSecretKey, consumerKey)
if c == nil {
return nil, err
}
@@ -46,6 +46,22 @@ func newOVH(m map[string]string, metadata json.RawMessage) (*ovhProvider, error)
return ovh, nil
}
func getOVHEndpoint(params map[string]string) string {
if ep, ok := params["endpoint"]; ok && ep != "" {
switch strings.ToLower(ep) {
case "eu":
return ovh.OvhEU
case "ca":
return ovh.OvhCA
case "us":
return ovh.OvhUS
default:
return ep
}
}
return ovh.OvhEU
}
func newDsp(conf map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
return newOVH(conf, metadata)
}
@@ -126,7 +142,16 @@ func (c *ovhProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, actual
return nil, err
}
if len(corrections) > 0 {
// Only refresh zone if there's a real modification
reportOnlyCorrections := true
for _, c := range corrections {
if c.F != nil {
reportOnlyCorrections = false
break
}
}
if !reportOnlyCorrections {
corrections = append(corrections, &models.Correction{
Msg: "REFRESH zone " + dc.Name,
F: func() error {