Alejandro Mery
1 year ago
3 changed files with 40 additions and 0 deletions
@ -0,0 +1,36 @@
|
||||
package dns |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
|
||||
"github.com/libdns/cloudflare" |
||||
"github.com/libdns/libdns" |
||||
) |
||||
|
||||
const ( |
||||
// CloudflareAPIToken is the environment variable
|
||||
// containing the API Token
|
||||
CloudflareAPIToken = "CLOUDFLARE_DNS_API_TOKEN" |
||||
) |
||||
|
||||
// Provider manages DNS entries
|
||||
type Provider interface { |
||||
libdns.RecordGetter |
||||
libdns.RecordDeleter |
||||
} |
||||
|
||||
// DefaultDNSProvider returns a cloudflare DNS provider
|
||||
// using an API Token from env [CloudflareAPIToken]
|
||||
func DefaultDNSProvider() (*cloudflare.Provider, error) { |
||||
s := os.Getenv(CloudflareAPIToken) |
||||
if s == "" { |
||||
return nil, fmt.Errorf("%q: %s", CloudflareAPIToken, "not found") |
||||
} |
||||
|
||||
p := &cloudflare.Provider{ |
||||
APIToken: s, |
||||
} |
||||
|
||||
return p, nil |
||||
} |
Loading…
Reference in new issue