Files
goodBaby/drivers/alidns/accountConfigChecker.go
T

55 lines
1.3 KiB
Go
Raw Normal View History

2026-08-30 16:03:32 +08:00
package alidns
import (
"fmt"
"github.com/alibabacloud-go/alidns-20150109/v5/client"
"github.com/ssdomei232/goodBaby/internal/meta"
)
type AliDNSAccountConfigValidator struct{}
func (v *AliDNSAccountConfigValidator) GetType() string { return AccountType }
func (v *AliDNSAccountConfigValidator) Validate(config string) error {
2026-09-12 15:32:27 +08:00
cfg, err := ParseAccountConfig(config)
2026-08-30 16:03:32 +08:00
if err != nil {
return err
}
if cfg.AK == "" || cfg.SK == "" {
return fmt.Errorf("阿里云账号配置不完整")
}
return nil
}
func (v *AliDNSAccountConfigValidator) Test(config string) error {
2026-09-12 15:32:27 +08:00
cfg, err := ParseAccountConfig(config)
2026-08-30 16:03:32 +08:00
if err != nil {
return err
}
2026-09-12 15:32:27 +08:00
aliDNSClient, err := newClient(cfg.AK, cfg.SK)
2026-08-30 16:03:32 +08:00
if err != nil {
return err
}
_, err = aliDNSClient.DescribeDnsProductInstances(&client.DescribeDnsProductInstancesRequest{})
if err != nil {
return err
}
return nil
}
func (v *AliDNSAccountConfigValidator) Meta() meta.AccountMeta {
return meta.AccountMeta{
Type: AccountType,
Label: "阿里云",
Description: "阿里云国内站",
Fields: []meta.Field{
{Key: "ak", Label: "Access Key", Type: meta.FieldPassword, Required: true, Secret: true, Placeholder: "xxxxxxxxx"},
{Key: "sk", Label: "Secret Key", Type: meta.FieldPassword, Required: true, Secret: true, Placeholder: "xxxxxxxxx"},
},
}
}