style: 变量命名

This commit is contained in:
Mmx233
2023-08-28 22:49:17 +08:00
parent 1df6000c71
commit e77448eeb9
10 changed files with 130 additions and 130 deletions

View File

@@ -20,9 +20,9 @@ func New(ttl int, conf map[string]interface{}, Http *http.Client) (*DnsProvider,
var p = DnsProvider{
TTL: ttl,
}
e := dnsUtil.DecodeConfig(conf, &p)
if e != nil {
return nil, e
err := dnsUtil.DecodeConfig(conf, &p)
if err != nil {
return nil, err
}
if p.Zone == "" {
@@ -34,36 +34,36 @@ func New(ttl int, conf map[string]interface{}, Http *http.Client) (*DnsProvider,
return nil, errors.New("cloudflare token 不能为空")
}
p.Api, e = cloudflare.NewWithAPIToken(p.Token, cloudflare.HTTPClient(Http))
return &p, e
p.Api, err = cloudflare.NewWithAPIToken(p.Token, cloudflare.HTTPClient(Http))
return &p, err
}
func (a DnsProvider) SetDomainRecord(domain, ip string) error {
records, _, e := a.Api.ListDNSRecords(context.Background(), a.ZoneResource, cloudflare.ListDNSRecordsParams{
records, _, err := a.Api.ListDNSRecords(context.Background(), a.ZoneResource, cloudflare.ListDNSRecordsParams{
Type: "A",
Name: domain,
})
if e != nil {
return e
if err != nil {
return err
}
if len(records) == 0 {
_, e = a.Api.CreateDNSRecord(context.Background(), a.ZoneResource, cloudflare.CreateDNSRecordParams{
_, err = a.Api.CreateDNSRecord(context.Background(), a.ZoneResource, cloudflare.CreateDNSRecordParams{
Type: "A",
Name: domain,
Content: ip,
TTL: a.TTL,
})
return e
return err
} else {
record := records[0]
if record.Content == ip {
return nil
}
_, e = a.Api.UpdateDNSRecord(context.Background(), a.ZoneResource, cloudflare.UpdateDNSRecordParams{
_, err = a.Api.UpdateDNSRecord(context.Background(), a.ZoneResource, cloudflare.UpdateDNSRecordParams{
ID: record.ID,
Content: ip,
})
return e
return err
}
}