build: remove dependency of mapstructre

This commit is contained in:
Mmx233
2024-03-23 19:49:11 +08:00
parent dbf46c715b
commit cac851d751
10 changed files with 68 additions and 74 deletions

View File

@@ -10,19 +10,20 @@ import (
"strings"
)
type DnsProvider struct {
Client *dnspod.Client `mapstructure:"-"`
TTL uint64 `mapstructure:"-"`
SecretId string `mapstructure:"secret_id"`
SecretKey string `mapstructure:"secret_key"`
type DnsPod struct {
SecretId string `json:"secret_id,omitempty" yaml:"secret_id,omitempty"`
SecretKey string `json:"secret_key,omitempty" yaml:"secret_key,omitempty"`
}
func New(ttl uint64, conf map[string]interface{}, Http http.RoundTripper) (*DnsProvider, error) {
var p = DnsProvider{TTL: ttl}
err := dnsUtil.DecodeConfig(conf, &p)
if err != nil {
return nil, err
}
type DnsProvider struct {
Client *dnspod.Client
TTL uint64
DnsPod
}
func New(ttl uint64, conf DnsPod, Http http.RoundTripper) (*DnsProvider, error) {
var p = DnsProvider{TTL: ttl, DnsPod: conf}
var err error
p.Client, err = dnspod.NewClient(common.NewCredential(p.SecretId, p.SecretKey), regions.Guangzhou, profile.NewClientProfile())
p.Client.WithHttpTransport(Http)
return &p, err