add cloudflare

This commit is contained in:
yoan
2024-09-02 13:21:37 +08:00
parent 1de39da699
commit 2b8fb9314f
4 changed files with 55 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
package applicant
import (
"certimate/internal/domain"
"encoding/json"
"os"
cf "github.com/go-acme/lego/v4/providers/dns/cloudflare"
)
type cloudflare struct {
option *ApplyOption
}
func NewCloudflare(option *ApplyOption) Applicant {
return &cloudflare{
option: option,
}
}
func (c *cloudflare) Apply() (*Certificate, error) {
access := &domain.CloudflareAccess{}
json.Unmarshal([]byte(c.option.Access), access)
os.Setenv("CLOUDFLARE_DNS_API_TOKEN", access.CloudflareDnsApiToken)
provider, err := cf.NewDNSProvider()
if err != nil {
return nil, err
}
return apply(c.option, provider)
}

View File

@@ -5,9 +5,11 @@ type AliyunAccess struct {
AccessKeySecret string `json:"accessKeySecret"`
}
type TencentAccess struct {
SecretId string `json:"secretId"`
SecretKey string `json:"secretKey"`
}
}
type CloudflareAccess struct {
CloudflareDnsApiToken string `json:"cloudflareDnsApiToken"`
}