-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathconstructor.go
More file actions
95 lines (88 loc) · 2.3 KB
/
Copy pathconstructor.go
File metadata and controls
95 lines (88 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Code generated from 'constructor.tmpl'; DO NOT EDIT.
package acme
import (
"fmt"
jsoniter "github.com/json-iterator/go"
"github.com/libdns/azure"
"github.com/libdns/cloudflare"
"github.com/libdns/cloudns"
"github.com/libdns/desec"
"github.com/libdns/digitalocean"
"github.com/haproxytech/dataplaneapi/acme/exec"
"github.com/libdns/gandi"
"github.com/libdns/godaddy"
"github.com/libdns/googleclouddns"
"github.com/libdns/hetzner/v2"
"github.com/libdns/infomaniak"
"github.com/libdns/inwx"
"github.com/libdns/ionos"
"github.com/libdns/linode"
"github.com/libdns/namecheap"
"github.com/libdns/netcup"
"github.com/libdns/ovh"
"github.com/libdns/porkbun"
"github.com/libdns/rfc2136"
"github.com/libdns/route53"
"github.com/libdns/scaleway"
"github.com/libdns/vultr/v2"
)
func NewDNSProvider(name string, params map[string]any) (DNSProvider, error) {
var prov DNSProvider
switch name {
case "azure":
prov = &azure.Provider{}
case "cloudflare":
prov = &cloudflare.Provider{}
case "cloudns":
prov = &cloudns.Provider{}
case "desec":
prov = &desec.Provider{}
case "digitalocean":
prov = &digitalocean.Provider{}
case "exec":
prov = &exec.Provider{}
case "gandi":
prov = &gandi.Provider{}
case "godaddy":
prov = &godaddy.Provider{}
case "googleclouddns":
prov = &googleclouddns.Provider{}
case "hetzner":
prov = &hetzner.Provider{}
case "infomaniak":
prov = &infomaniak.Provider{}
case "inwx":
prov = &inwx.Provider{}
case "ionos":
prov = &ionos.Provider{}
case "linode":
prov = &linode.Provider{}
case "namecheap":
prov = &namecheap.Provider{}
case "netcup":
prov = &netcup.Provider{}
case "ovh":
prov = &ovh.Provider{}
case "porkbun":
prov = &porkbun.Provider{}
case "rfc2136":
prov = &rfc2136.Provider{}
case "route53":
prov = &route53.Provider{}
case "scaleway":
prov = &scaleway.Provider{}
case "vultr":
prov = &vultr.Provider{}
default:
return nil, fmt.Errorf("invalid DNS provider name: '%s'", name)
}
jsoni := jsoniter.ConfigCompatibleWithStandardLibrary
js, err := jsoni.Marshal(params)
if err != nil {
return nil, fmt.Errorf("failed to marshal params for DNS provider %s: %w", name, err)
}
if err = jsoni.Unmarshal(js, prov); err != nil {
return nil, fmt.Errorf("invalid params for DNS provider %s: %w", name, err)
}
return prov, nil
}